Commit dfe4f9a3 by Wyh

1、外送接單訂單數量沒刷新問題 2、針式打印輪詢查看打印狀態 3、打印字體大小預設問題 4、供應鏈SN食材

parent e716d712
......@@ -39,6 +39,7 @@ import com.gingersoft.gsa.delivery_pick_mode.data.model.bean.*
import com.gingersoft.gsa.delivery_pick_mode.ui.adapter.DeliveryAdapter
import com.gingersoft.gsa.delivery_pick_mode.util.OtherOrderUtils
import com.jess.arms.utils.ArmsUtils
import kotlinx.android.synthetic.main.activity_other_order.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
......@@ -265,6 +266,10 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
receiveOrder()
} else {
receiverProgress = 0
//獲取每個狀態的訂單數量
getOrderGroupNum()
//查詢預約單和即時單數量
getOrderStatistics(fragmentStatus[0])
}
}
}
......
......@@ -462,13 +462,14 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
if (cb_takeaway_auto_receiving_orders.isChecked) {
//查詢待確定的訂單id
pageViewModel.getToBeConfirmedOrderIds()
}
} else {
//獲取每個狀態的訂單數量
pageViewModel.getOrderGroupNum()
//查詢預約單和即時單數量
pageViewModel.getOrderStatistics(fragmentStatus[view_pager.currentItem])
}
}
}
})
it.execute {
if (it) {
......
......@@ -49,7 +49,7 @@ public class EpsonPrint implements ReceiveListener {
/**
* 初始化
*
* @return
* @return 初始化是否成功
*/
public boolean initializeObject(Context context, ReceiveListener receiveListener, OnPrjPrintResultListener onPrjPrintResultListener) {
try {
......@@ -84,7 +84,7 @@ public class EpsonPrint implements ReceiveListener {
if (e instanceof Epos2Exception) {
//Note: If printer is processing such as printing and so on, the disconnect API returns ERR_PROCESSING.
if (((Epos2Exception) e).getErrorStatus() == Epos2Exception.ERR_PROCESSING) {
//报错
} else {
break;
}
......@@ -111,7 +111,7 @@ public class EpsonPrint implements ReceiveListener {
/**
* 創建打印數據
*
* @return
* @return 创建数据是否成功
*/
private boolean createPrintData(Bitmap bitmap) {
try {
......@@ -282,6 +282,11 @@ public class EpsonPrint implements ReceiveListener {
}
}
/**
* 最后一次添加到队列的时间
*/
private long lastInputTime = 0;
public void putPrintData(String ip, Bitmap bitmap, String foodId) {
//把bitmap存隊列中,下次打印
if (bitmaps.size() <= 0) {
......@@ -292,6 +297,11 @@ public class EpsonPrint implements ReceiveListener {
if (isPrint) {
LogUtil.d("eee", "prj針式打印機隊列中,前面還有" + bitmaps.size() + "個任務");
PrinterFlowProxy.newInstance().dispatchConnectionBefore("針式打印機隊列中,前面還有" + bitmaps.size() + "個任務", ip, 0, 0, 0);
//做一個校驗,如果三十秒後,isPrint還是true,就手動改為false。
if (System.currentTimeMillis() - lastInputTime > 30 * 1000) {
isPrint = true;
printData(ip, foodId, bitmap);
}
return;
}
isPrint = true;
......@@ -299,9 +309,11 @@ public class EpsonPrint implements ReceiveListener {
}
private void printData(String ip, String ids, Bitmap bitmap) {
//记录下本次打印的时间
lastInputTime = System.currentTimeMillis();
PrinterFlowProxy.newInstance().dispatchPrinterDataBefore(0, 0, "針式打印機", ip);
mPrinter.clearCommandBuffer();
LogUtil.d("eee", "prj針式打印機創建數據中任務數:" + bitmaps.size());
LogUtil.d("eee", "prj針式打印機創建數據中:" + ids + "——IP地址:" + ip + "任務數:" + bitmaps.size());
if (!createPrintData(bitmap)) {
LogUtil.d("eee", "prj針式打印機創建數據失敗");
//如果是創建數據失敗,說明這個數據有問題,移除掉
......@@ -312,10 +324,10 @@ public class EpsonPrint implements ReceiveListener {
connectByIp(ip, mPrinter.getStatus());
//獲取打印機狀態
PrinterStatusInfo statusInfo = mPrinter.getStatus();
LogUtil.d("eee", "prj針式打印機:" + "紙張狀態:" + statusInfo.getPaper() + "連接狀態:" + statusInfo.getConnection() + ",任務數:" + bitmaps.size());
LoganManager.w_printer(TAG, "prj針式打印機:" + "紙張狀態:" + statusInfo.getPaper() + "連接狀態:" + statusInfo.getConnection() + ",任務數:" + bitmaps.size());
if (statusInfo.getConnection() != 1) {
//未連接到打印機
LogUtil.d("eee", "prj針式打印機連接失敗:" + ids);
LoganManager.w_printer(TAG, "連接失敗::" + statusInfo.getConnection() + "prj:" + ids);
printErrorProcess(ids, bitmap, new Exception("針式打印機連接失敗" + ip), PrintSocketHolder.ERROR_7);
return;
} else if (statusInfo.getPaper() != 0) {
......@@ -347,6 +359,7 @@ public class EpsonPrint implements ReceiveListener {
* @param bitmap
*/
private void printErrorProcess(String ids, Bitmap bitmap, Exception e, int errorCode) {
LoganManager.w_printer(TAG, "當前" + ids + "執行下一個printErrorProcess");
bitmaps.remove(bitmap);
prjIds.remove(ids);
PrinterFlowProxy.newInstance().dispatchConnectionError(e);
......@@ -421,6 +434,7 @@ public class EpsonPrint implements ReceiveListener {
}
private void updatePrintState(String ids, int code) {
LoganManager.w_printer(TAG, "修改打印狀態updatePrintState" + ids + "_" + code + "回調接口:" + onPrjPrintResultListener);
if (onPrjPrintResultListener != null) {
onPrjPrintResultListener.onResult(code, ids);
}
......@@ -465,11 +479,20 @@ public class EpsonPrint implements ReceiveListener {
*/
private void isExecutionNextTask() {
if (bitmaps.size() > 0) {
LoganManager.w_printer(TAG, "isExecutionNextTask" + bitmaps.size());
printData(ipAddress, prjIds.get(0), bitmaps.get(0));
} else {
LoganManager.w_printer(TAG, "isExecutionNextTask任務完成");
isPrint = false;
disconnectPrinter();
finalizeObject();
}
}
public void canNextTask() {
//距离上一次打印超过三十秒并且状态还是打印中。
if (System.currentTimeMillis() - lastInputTime > 30 * 1000 && isPrint) {
isExecutionNextTask();
}
}
}
......@@ -169,6 +169,7 @@ public class PrjService extends Service implements ReceiveListener {
//輪詢時,關閉打印機連接,避免一直佔用打印機socket連接
EpsonPrint.getInstance().disconnectPrinter();
EpsonPrint.getInstance().finalizeObject();
EpsonPrint.getInstance().canNextTask();
//獲取prj數據
getPrjInfo();
});
......@@ -223,7 +224,7 @@ public class PrjService extends Service implements ReceiveListener {
}
}
private String prjJson = "{\"success\":true,\"sysTime\":1614581072400,\"data\":{\"K3\":[{\"id\":44419,\"printerDeviceId\":149,\"status\":2,\"orderNo\":\"233212281076117397\",\"orderTime\":2021,\"sender\":\"\",\"sendTime\":\"盡快送達 預計 15:49-16:04\",\"person\":0,\"number\":1,\"orderDetailsTime\":\"Mar 1, 2021 2:43:38 PM\",\"orderDetailsId\":12895,\"productName\":\"鬥獸場大什扒\",\"productName2\":\"\",\"productName3\":\"\",\"parentId\":0,\"type\":3,\"createTime\":1614581044514,\"productId\":27921,\"requests\":1,\"actualPrinterDeviceId\":149,\"flyPrinterDeviceId\":150,\"takeFoodCode\":\"1074\",\"billNo\":\"\",\"orderType\":2,\"userName\":\"wyh\",\"isFirstSendOrder\":1,\"quantity\":49,\"memberName\":\"\"}],\"K4\":[{\"id\":44420,\"printerDeviceId\":150,\"status\":2,\"orderNo\":\"233212281076117397\",\"orderTime\":2021,\"sender\":\"\",\"sendTime\":\"盡快送達 預計 15:49-16:04\",\"person\":0,\"number\":1,\"orderDetailsTime\":\"Mar 1, 2021 2:43:38 PM\",\"orderDetailsId\":12896,\"productName\":\"芝士焗龍蝦\",\"productName2\":\"\",\"productName3\":\"\",\"parentId\":0,\"type\":3,\"createTime\":1614581044521,\"productId\":27926,\"requests\":1,\"actualPrinterDeviceId\":150,\"takeFoodCode\":\"1074\",\"billNo\":\"\",\"orderType\":2,\"userName\":\"wyh\",\"isFirstSendOrder\":1,\"quantity\":50,\"memberName\":\"\"}]}}\n";
// private String prjJson = "{\"success\":true,\"sysTime\":1614581072400,\"data\":{\"K2\":[{\"id\":92701,\"printerDeviceId\":65,\"status\":2,\"tableName\":\"2\",\"orderNo\":\"0020\",\"orderTime\":2021,\"person\":2,\"number\":1,\"orderDetailsTime\":\"Mar 27, 2021 11:43:57 AM\",\"orderDetailsId\":59507759,\"productName\":\"海家酸菜魚 (辣)K2\",\"productName2\":\"\",\"productName3\":\"\",\"parentId\":0,\"type\":3,\"createTime\":1616816636920,\"productId\":63323,\"requests\":1,\"actualPrinterDeviceId\":65,\"orderType\":1,\"isFirstSendOrder\":2,\"quantity\":89,\"memberName\":\"BARRY1\"},{\"id\":92702,\"printerDeviceId\":65,\"status\":3,\"tableName\":\"2\",\"orderNo\":\"0020\",\"orderTime\":2021,\"person\":2,\"number\":1,\"orderDetailsTime\":\"Mar 27, 2021 11:43:57 AM\",\"orderDetailsId\":59507760,\"productName\":\"蓮藕\",\"parentId\":59507759,\"type\":4,\"createTime\":1616816636922,\"productId\":29923,\"requests\":1,\"actualPrinterDeviceId\":65,\"orderType\":1,\"isFirstSendOrder\":2,\"quantity\":89,\"memberName\":\"BARRY1\"},{\"id\":92703,\"printerDeviceId\":65,\"status\":3,\"tableName\":\"2\",\"orderNo\":\"0020\",\"orderTime\":2021,\"person\":2,\"number\":1,\"orderDetailsTime\":\"Mar 27, 2021 11:43:57 AM\",\"orderDetailsId\":59507761,\"productName\":\"腐竹\",\"parentId\":59507759,\"type\":4,\"createTime\":1616816636928,\"productId\":29928,\"requests\":1,\"actualPrinterDeviceId\":65,\"orderType\":1,\"isFirstSendOrder\":2,\"quantity\":89,\"memberName\":\"BARRY1\"},{\"id\":92704,\"printerDeviceId\":65,\"status\":3,\"tableName\":\"2\",\"orderNo\":\"0020\",\"orderTime\":2021,\"person\":2,\"number\":1,\"orderDetailsTime\":\"Mar 27, 2021 11:43:57 AM\",\"orderDetailsId\":59507762,\"productName\":\"木耳\",\"parentId\":59507759,\"type\":4,\"createTime\":1616816636934,\"productId\":29924,\"requests\":1,\"actualPrinterDeviceId\":65,\"orderType\":1,\"isFirstSendOrder\":2,\"quantity\":89,\"memberName\":\"BARRY1\"},{\"id\":92705,\"printerDeviceId\":65,\"status\":3,\"tableName\":\"2\",\"orderNo\":\"0020\",\"orderTime\":2021,\"person\":2,\"number\":1,\"orderDetailsTime\":\"Mar 27, 2021 11:43:57 AM\",\"orderDetailsId\":59507763,\"productName\":\"豆乾\",\"parentId\":59507759,\"type\":4,\"createTime\":1616816636939,\"productId\":29929,\"requests\":1,\"actualPrinterDeviceId\":65,\"orderType\":1,\"isFirstSendOrder\":2,\"quantity\":89,\"memberName\":\"BARRY1\"}]}}\n";
private void newPrint(String json) {
Map<String, List<PrjBean>> listMap = new HashMap<>();
......
......@@ -112,18 +112,28 @@ public class MyPrintUtils {
if (defaultPrint.getFoodIsBold() == 0) {
defaultPrint.setFoodIsBold(printCurrencyBean.getFoodIsBold());
}
if (PrinterDeviceBean.DEFAULT_FONT_SIZE.equals(defaultPrint.getFoodFont())) {
if (PrinterDeviceBean.DEFAULT_FONT_SIZE.equals(defaultPrint.getFoodFont())
|| PrinterDeviceBean.PRESET.equals(defaultPrint.getFoodFont())) {
if (PrinterDeviceBean.PRESET.equals(printCurrencyBean.getFoodFont())) {
defaultPrint.setFoodFont("18");
} else {
defaultPrint.setFoodFont(printCurrencyBean.getFoodFont());
}
}
if (defaultPrint.getFoodIsItalic() == 0) {
defaultPrint.setFoodIsItalic(printCurrencyBean.getFoodIsItalic());
}
if (defaultPrint.getModifierIsBold() == 0) {
defaultPrint.setModifierIsBold(printCurrencyBean.getModifierIsBold());
}
if (PrinterDeviceBean.DEFAULT_FONT_SIZE.equals(defaultPrint.getModifierFont())) {
if (PrinterDeviceBean.DEFAULT_FONT_SIZE.equals(defaultPrint.getModifierFont())
|| PrinterDeviceBean.PRESET.equals(defaultPrint.getModifierFont())) {
if (PrinterDeviceBean.PRESET.equals(printCurrencyBean.getModifierFont())) {
defaultPrint.setModifierFont("16");
} else {
defaultPrint.setModifierFont(printCurrencyBean.getModifierFont());
}
}
if (defaultPrint.getModifierIsItalic() == 0) {
defaultPrint.setModifierIsItalic(printCurrencyBean.getModifierIsItalic());
}
......@@ -134,10 +144,12 @@ public class MyPrintUtils {
if (printCurrencyBean == null) {
// 如果沒有預設,那麼判斷打印機字體大小是不是設置為預設
// 如果是預設,那麼手動給設置食品字體大小,不然打印不出來食品
if (PrinterDeviceBean.DEFAULT_FONT_SIZE.equals(defaultPrint.getFoodFont())) {
if (PrinterDeviceBean.DEFAULT_FONT_SIZE.equals(defaultPrint.getFoodFont())
|| PrinterDeviceBean.PRESET.equals(defaultPrint.getFoodFont())) {
defaultPrint.setFoodFont("18");
}
if (PrinterDeviceBean.DEFAULT_FONT_SIZE.equals(defaultPrint.getModifierFont())) {
if (PrinterDeviceBean.DEFAULT_FONT_SIZE.equals(defaultPrint.getModifierFont())
|| PrinterDeviceBean.PRESET.equals(defaultPrint.getModifierFont())) {
defaultPrint.setModifierFont("16");
}
}
......
......@@ -11,6 +11,9 @@ android {
lintOptions {
abortOnError false
}
dataBinding {
enabled true
}
defaultConfig {
if (project.ext.runAsApp) {
applicationId "com.gingersoft.supply_chain"
......
package com.gingersoft.supply_chain.mvp.bean;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2021/3/30
* Time: 10:19
* Use: 食材列表展示數據
*/
public class BuyIngredientsBean {
/**
* 分類id
*/
public int id;
/**
* 分類名
*/
public String categoryName;
/**
* 分類的id
*/
public int parentId;
/**
* 食材信息
*/
public List<PurchaseFoodBean> purchaseFoodList;
}
package com.gingersoft.supply_chain.mvp.bean;
/**
* 这个类是用来记录分组列表中组的结构的。
* 通过GroupStructure记录每个组是否有头部,是否有尾部和子项的数量。从而能方便的计算
* 列表的长度和每个组的组头、组尾和子项在列表中的位置。
*/
public class GroupStructure {
private boolean hasHeader;
private boolean hasFooter;
private int childrenCount;
public GroupStructure(boolean hasHeader, boolean hasFooter, int childrenCount) {
this.hasHeader = hasHeader;
this.hasFooter = hasFooter;
this.childrenCount = childrenCount;
}
public boolean hasHeader() {
return hasHeader;
}
public void setHasHeader(boolean hasHeader) {
this.hasHeader = hasHeader;
}
public boolean hasFooter() {
return hasFooter;
}
public void setHasFooter(boolean hasFooter) {
this.hasFooter = hasFooter;
}
public int getChildrenCount() {
return childrenCount;
}
public void setChildrenCount(int childrenCount) {
this.childrenCount = childrenCount;
}
}
......@@ -15,10 +15,9 @@ import lombok.Data;
public class OrderWareHouseBean {
private int status;
private int orderId;
private List<String> encodeFoodNos;
private PurchaseWarehousingOrder purchaseWarehousingOrder;
private List<PurchaseWarehousingOrderDetail> purchaseWarehousingOrderDetailsTOS;
@Data
public static class PurchaseWarehousingOrder {
/**
......
......@@ -16,13 +16,15 @@ public class PurchaseConsumeSnBean {
public int consumeQuantity;
public int purchaseConsumeReasonId;
public String remarks;
public List<PurchaseFoodEncodeSn> purchaseFoodEncodeSn;
public static class PurchaseFoodEncodeSn {
public PurchaseFoodEncodeSn(String encodeSnNo) {
this.encodeSnNo = encodeSnNo;
}
public String encodeSnNo;
}
// public String encodeFoodNos;
public List<String> encodeFoodNos;
// public List<PurchaseFoodEncodeSn> purchaseFoodEncodeSn;
//
// public static class PurchaseFoodEncodeSn {
// public PurchaseFoodEncodeSn(String encodeSnNo) {
// this.encodeSnNo = encodeSnNo;
// }
//
// public String encodeSnNo;
// }
}
package com.gingersoft.supply_chain.mvp.bean;
import java.io.Serializable;
import java.util.Objects;
/**
* @author 宇航.
......@@ -33,10 +34,18 @@ public class PurchaseFoodEncodeSn implements Serializable {
* 是否新增
*/
public boolean newAdd = false;
/**
* 1未消耗
*/
public int status = 1;
public PurchaseFoodEncodeSn() {
}
public PurchaseFoodEncodeSn(String encodeSnNo) {
this.encodeSnNo = encodeSnNo;
}
public PurchaseFoodEncodeSn(String encodeFoodNo, String encodeOrderNo, String encodeSnNo) {
this.encodeFoodNo = encodeFoodNo;
this.encodeOrderNo = encodeOrderNo;
......@@ -66,4 +75,32 @@ public class PurchaseFoodEncodeSn implements Serializable {
public void setEncodeSnNo(String encodeSnNo) {
this.encodeSnNo = encodeSnNo;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
PurchaseFoodEncodeSn that = (PurchaseFoodEncodeSn) o;
return createTime == that.createTime &&
updateTime == that.updateTime &&
createUid == that.createUid &&
updateUid == that.updateUid &&
newAdd == that.newAdd &&
status == that.status &&
Objects.equals(encodeFoodNo, that.encodeFoodNo) &&
Objects.equals(encodeOrderNo, that.encodeOrderNo) &&
Objects.equals(encodeSnNo, that.encodeSnNo) &&
Objects.equals(id, that.id) &&
Objects.equals(userName, that.userName);
}
@Override
public int hashCode() {
return Objects.hash(encodeFoodNo, encodeOrderNo, encodeSnNo, id, createTime, updateTime, createUid, updateUid, userName, newAdd, status);
}
}
......@@ -35,6 +35,10 @@ public class Constant {
* 上傳圖片類型:訂單收貨圖
*/
public static final int UPLOAD_PIC_TYPE_ORDER = 2;
/**
* 逗號分隔符
*/
public static final String COMMA_SEPARATED = ",";
public static final String GET_INFO_ERROR = "數據獲取失敗,請稍候再試";
public static final String INFO_SYNTAX_ERROR = "數據解析失敗,請聯繫開發人員";
......
......@@ -2,6 +2,7 @@ package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean;
import com.gingersoft.supply_chain.mvp.bean.FoodByCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.FoodListInfoBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
......@@ -52,7 +53,7 @@ public interface BuyIngredientsContract {
* 加載食品
* @param food
*/
void loadFood(int categoryId, List<QMUISection<CategoryBean, PurchaseFoodBean>> food);
void loadFood(List<BuyIngredientsBean> buyIngredientsBeans);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
......
......@@ -34,7 +34,9 @@ public interface OrderDetailsContract {
void buyAgain();
void querySnCodeSuccess(int position, PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean infoVosBean);
void nextFood();
void querySnCodeSuccess(int position, PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean infoVosBean, boolean singerFood);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
......@@ -62,5 +64,13 @@ public interface OrderDetailsContract {
* @return
*/
Observable<BaseResult> buyAgainByFoodIds(Map<String, Object> map);
/**
* 刪除sn碼
* @param map
* @return
*/
Observable<BaseResult> deleteSnCode(Map<String, Object> map);
}
}
......@@ -67,7 +67,7 @@ public interface WarehouseDetailsContract {
* @param consumeReasonDesc 消耗原因
* @param consumptionNum 消耗数量
*/
void printConsumeOrder(String consumeReasonDesc, int consumptionNum);
void printConsumeOrder(List<String> snCodes, String consumeReasonDesc, int consumptionNum);
/**
* 跳转到sn码页面
......@@ -98,9 +98,14 @@ public interface WarehouseDetailsContract {
* 獲取庫存數量
*/
Observable<BaseResult> getWarehousingNum(Map<String, Object> map);
/**
* 獲取庫存中的Sn
* @param foodNo 食材編號
*/
Observable<BaseResult> queryInStockSnCodes(String foodNo);
/**
* 獲取Sn列表
* 獲取出入庫流水的Sn列表
*/
Observable<BaseResult> querySnCodeList(Map<String, Object> map);
......
......@@ -82,4 +82,9 @@ public class OrderDetailsModel extends BaseModel implements OrderDetailsContract
public Observable<BaseResult> buyAgainByFoodIds(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).buyAgainByFoodIds(map);
}
@Override
public Observable<BaseResult> deleteSnCode(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).deleteSnCode(map);
}
}
\ No newline at end of file
......@@ -77,6 +77,11 @@ public class WarehouseDetailsModel extends BaseModel implements WarehouseDetails
}
@Override
public Observable<BaseResult> queryInStockSnCodes(String foodNo) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).queryInStockSnCodes(foodNo);
}
@Override
public Observable<BaseResult> querySnCodeList(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).querySnCodeList(map);
}
......
......@@ -4,6 +4,7 @@ import android.app.Application;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean;
import com.gingersoft.supply_chain.mvp.bean.CategoryFoodTreeBean;
import com.gingersoft.supply_chain.mvp.bean.FoodByCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
......@@ -64,7 +65,8 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
*/
private List<CategoryFoodTreeBean> categoryFoodTreeBeans;
private Map<Integer, List<QMUISection<CategoryBean, PurchaseFoodBean>>> foodSectionMap = new HashMap<>();
private List<BuyIngredientsBean> buyIngredientsBeans;
// private Map<Integer, List<QMUISection<CategoryBean, PurchaseFoodBean>>> foodSectionMap = new HashMap<>();
/**
* 是否正在加載食品中
*/
......@@ -168,29 +170,29 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
public void getFood(int parentCategoryId) {
List<QMUISection<CategoryBean, PurchaseFoodBean>> foodSections = foodSectionMap.get(parentCategoryId);
if (foodSections == null) {
getFoodByCategoryId(parentCategoryId);
} else {
mRootView.loadFood(parentCategoryId, foodSections);
}
// List<QMUISection<CategoryBean, PurchaseFoodBean>> foodSections = foodSectionMap.get(parentCategoryId);
// if (foodSections == null) {
// getFoodByCategoryId(parentCategoryId);
// } else {
// mRootView.loadFood(parentCategoryId, foodSections);
// }
}
/**
* 根據一級分類獲取下面所有包括子分類的食品
*
* @param parentCategoryId 父分類id
*/
private void getFoodByCategoryId(int parentCategoryId) {
public void getFoodByCategory(OrderCategoryBean.FoodCategoryTrees categoryTrees) {
//先看看這個分類的食材有沒有緩存,沒有緩衝再加載
Map<String, Object> map = new HashMap<>(5);
map.put("pageSize", 1000);
map.put("pageIndex", 0);
Constant.addBrandId(map);
Constant.addRestaurantId(map);
map.put("parentId", parentCategoryId);
map.put("parentId", categoryTrees.getId());
mModel.getFoodByCategory(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("獲取中..."))
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterNext(dis -> mRootView.hideLoading())
......@@ -204,9 +206,9 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
savFoodToCategory(info);
//這個接口是一級分類才調用,所以直接顯示所有食材,讓用戶可以滾動列表
//將食品和分類整合到一起,List<QMUISection<CategoryBean, PurchaseFoodBean>>
val sections = foodToList(info.getData());
foodSectionMap.put(parentCategoryId, sections);
mRootView.loadFood(parentCategoryId, sections);
// val sections = foodToList(info.getData());
// foodSectionMap.put(parentCategoryId, sections);
// mRootView.loadFood(parentCategoryId, sections);
// mRootView.loadRightFoodIngredients(filterThisCategoryFood(categoryId, info.getData()));
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
......@@ -226,10 +228,10 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
public Void doInIOThread(FoodByCategoryResultBean info) {
//將本次獲取到的食品存入到緩存中
for (CategoryFoodTreeBean categoryFoodTreeBean : categoryFoodTreeBeans) {
if (categoryFoodTreeBean.getCategoryIds().contains(parentCategoryId)) {
categoryFoodTreeBean.setFoodInfo(info.getData());
break;
}
// if (categoryFoodTreeBean.getCategoryIds().contains(parentCategoryId)) {
// categoryFoodTreeBean.setFoodInfo(info.getData());
// break;
// }
}
return null;
}
......@@ -243,10 +245,12 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
*
* @return
*/
public List<QMUISection<CategoryBean, PurchaseFoodBean>> foodToList(List<PurchaseFoodBean> data) {
public List<QMUISection<CategoryBean, PurchaseFoodBean>> foodToList(OrderCategoryBean.FoodCategoryTrees categoryTrees, List<PurchaseFoodBean> data) {
if (data == null) {
return null;
}
BuyIngredientsBean buyIngredientsBean = new BuyIngredientsBean();
List<QMUISection<CategoryBean, PurchaseFoodBean>> sections = new ArrayList<>();
CategoryBean categoryBean = new CategoryBean();
List<PurchaseFoodBean> purchaseFoodBeans = new ArrayList<>();
......
......@@ -130,9 +130,9 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
mModel.getFoodIngredientsData(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
.doAfterTerminate(() -> mRootView.hideLoading())
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.observeOn(Schedulers.io())
.subscribe(new ErrorHandleSubscriber<FoodListInfoBean>(mErrorHandler) {
......@@ -229,7 +229,7 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
}
mModel.getFoodBySupplierId(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("獲取中..."))
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
......
......@@ -248,8 +248,9 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
* @param purchaseOrderDetailsInfoVosBeans 選中的食品
*/
public void addWarehouse(int state, String remark, double totalAmount, List<PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean> purchaseOrderDetailsInfoVosBeans) {
List<OrderWareHouseBean.PurchaseWarehousingOrderDetail> purchaseWarehousingOrderDetails = transformWareHoses(purchaseOrderDetailsInfoVosBeans);
OrderWareHouseBean wareHouseBean = getWareHouseBean(state, remark, totalAmount, purchaseWarehousingOrderDetails);
OrderWareHouseBean wareHouseBean = new OrderWareHouseBean();
List<OrderWareHouseBean.PurchaseWarehousingOrderDetail> purchaseWarehousingOrderDetails = transformWareHoses(wareHouseBean, purchaseOrderDetailsInfoVosBeans);
wareHouseBean = getWareHouseBean(state, remark, totalAmount, wareHouseBean, purchaseWarehousingOrderDetails);
if (wareHouseBean == null) {
return;
}
......@@ -288,7 +289,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
Constant.addBrandId(map);
StringBuilder stringBuilder = new StringBuilder();
for (PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean item : data) {
stringBuilder.append(item.getPurchaseFoodId()).append(",");
stringBuilder.append(item.getPurchaseFoodId()).append(Constant.COMMA_SEPARATED);
}
map.put("ids", stringBuilder.substring(0, stringBuilder.length() - 1));
mModel.buyAgainByFoodIds(map)
......@@ -325,11 +326,10 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
/**
* 生成入庫對象
*/
private OrderWareHouseBean getWareHouseBean(int state, String remark, double totalAmount, List<OrderWareHouseBean.PurchaseWarehousingOrderDetail> purchaseWarehousingOrderDetails) {
private OrderWareHouseBean getWareHouseBean(int state, String remark, double totalAmount, OrderWareHouseBean orderWareHouseBean, List<OrderWareHouseBean.PurchaseWarehousingOrderDetail> purchaseWarehousingOrderDetails) {
if (purchaseWarehousingOrderDetails == null) {
return null;
}
OrderWareHouseBean orderWareHouseBean = new OrderWareHouseBean();
orderWareHouseBean.setStatus(state);
orderWareHouseBean.setOrderId(orderId);
......@@ -348,13 +348,14 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
purchaseWarehousingOrder.setTotalPrice(totalAmount);
orderWareHouseBean.setPurchaseWarehousingOrder(purchaseWarehousingOrder);
orderWareHouseBean.setPurchaseWarehousingOrderDetailsTOS(purchaseWarehousingOrderDetails);
return orderWareHouseBean;
}
/**
* 將訂單轉換為入庫單
*/
private List<OrderWareHouseBean.PurchaseWarehousingOrderDetail> transformWareHoses(List<PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean> purchaseOrderDetailsInfoVosBeans) {
private List<OrderWareHouseBean.PurchaseWarehousingOrderDetail> transformWareHoses(OrderWareHouseBean wareHouseBean, List<PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean> purchaseOrderDetailsInfoVosBeans) {
if (purchaseOrderDetailsInfoVosBeans == null || purchaseOrderDetailsInfoVosBeans.size() <= 0) {
mRootView.showMessage(NULL_INFO_ERROR);
return null;
......@@ -380,18 +381,19 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
purchaseWarehousingOrderDetail.setPurchaseWarehousingUnit(wareHousingUnitBean);
//sn碼
List<PurchaseFoodEncodeSn> snList = null;
// StringBuilder snCode = new StringBuilder();
List<String> snCodes = null;
if (purchaseOrderDetailsInfoVosBean.getPurchaseFoodEncodeSns() != null) {
snList = new ArrayList<>();
snCodes = new ArrayList<>();
//只遍歷出新增的
for (PurchaseFoodEncodeSn purchaseFoodEncodeSn : purchaseOrderDetailsInfoVosBean.getPurchaseFoodEncodeSns()) {
if (purchaseFoodEncodeSn.newAdd) {
snList.add(purchaseFoodEncodeSn);
// snCode.append(purchaseFoodEncodeSn.getEncodeSnNo()).append(",");
snCodes.add(purchaseFoodEncodeSn.getEncodeSnNo());
}
}
// snCode.substring(0, snCode.length() - 1);
}
wareHouseBean.setEncodeFoodNos(snCodes);
purchaseWarehousingOrderDetail.setPurchaseFoodEncodeSn(snList);
purchaseWarehousingOrderDetails.add(purchaseWarehousingOrderDetail);
}
......@@ -426,9 +428,53 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
}
/**
* 是否全是待收货食材
*
* @param data 食材信息
* @return
*/
public boolean allWaitReceived(List<PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean> data) {
if (data != null) {
for (PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean datum : data) {
if (datum.getStatus() != PurchaseOrderDetailsBean.WAIT_RECEIVED) {
return false;
}
}
return true;
}
return true;
}
/**
* 刪除Sn碼
*/
public void deleteSn(String enCodeOrderNo, String encodeFoodNo, String encodeSnNo) {
Map<String, Object> map = new HashMap<>(3);
map.put("encodeOrderNo", enCodeOrderNo);
map.put("encodeFoodNo", encodeFoodNo);
map.put("encodeSnNo", encodeSnNo);
mModel.deleteSnCode(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.DELETE_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseResult info) {
if (info.isSuccess()) {
mRootView.showMessage(Constant.DELETE_SUCCESS);
}
}
});
}
/**
* 查詢商品sn碼
*/
public void querySnCodes(int position, PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean infoVosBean) {
public void querySnCodes(int position, PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean infoVosBean, boolean singerFood) {
mModel.querySnCodes(infoVosBean.getFoodNo(), infoVosBean.getOrderNo())
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.QUERY_LOADING))
......@@ -441,8 +487,28 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
public void onNext(@NonNull BaseResult info) {
if (info.isSuccess()) {
List<PurchaseFoodEncodeSn> purchaseFoodEncodeSns = GsonUtils.jsonToList(info.getData(), PurchaseFoodEncodeSn.class);
if (purchaseFoodEncodeSns != null) {
if (infoVosBean.getPurchaseFoodEncodeSns() == null) {
infoVosBean.setPurchaseFoodEncodeSns(purchaseFoodEncodeSns);
mRootView.querySnCodeSuccess(position, infoVosBean);
} else {
for (PurchaseFoodEncodeSn purchaseFoodEncodeSn : purchaseFoodEncodeSns) {
if (!infoVosBean.getPurchaseFoodEncodeSns().contains(purchaseFoodEncodeSn)) {
infoVosBean.getPurchaseFoodEncodeSns().add(purchaseFoodEncodeSn);
}
}
}
}
mRootView.querySnCodeSuccess(position, infoVosBean, singerFood);
} else if (!singerFood) {
mRootView.nextFood();
}
}
@Override
public void onError(Throwable t) {
super.onError(t);
if (!singerFood) {
mRootView.nextFood();
}
}
});
......
......@@ -123,8 +123,8 @@ public class WareHouseListPresenter extends BasePresenter<WareHouseListContract.
}
Constant.addRestaurantId(map);
Constant.addBrandId(map);
Constant.addPageSize(map);
map.put("pageIndex", pageIndex * Constant.PAGE_SIZE);
map.put("pageSize", 30);
map.put("pageIndex", pageIndex * 30);
mModel.getWarehousing(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
......
......@@ -5,6 +5,7 @@ import android.view.View;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.utils.CollectionUtils;
import com.gingersoft.gsa.cloud.common.utils.JsonUtils;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
......@@ -185,13 +186,9 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
purchaseConsumeSnBean.foodNo = purchaseWarehousingOrderDetailsVO.getFoodNo();
purchaseConsumeSnBean.purchaseConsumeReasonId = consumeReasonBean.getId();
purchaseConsumeSnBean.remarks = remarks;
if (snCodes != null) {
List<PurchaseConsumeSnBean.PurchaseFoodEncodeSn> snList = new ArrayList<>();
for (String snCode : snCodes) {
snList.add(new PurchaseConsumeSnBean.PurchaseFoodEncodeSn(snCode));
}
purchaseConsumeSnBean.consumeQuantity = snList.size();
purchaseConsumeSnBean.purchaseFoodEncodeSn = snList;
if (CollectionUtils.isNotNullOrEmpty(snCodes)) {
purchaseConsumeSnBean.encodeFoodNos = snCodes;
purchaseConsumeSnBean.consumeQuantity = snCodes.size();
} else {
purchaseConsumeSnBean.consumeQuantity = consumeQuantity;
}
......@@ -208,7 +205,7 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
public void onNext(BaseResult baseResult) {
if (baseResult != null && baseResult.isSuccess()) {
if (whetherPrint) {
mRootView.printConsumeOrder(consumeReasonBean.getDescription(), consumeQuantity);
mRootView.printConsumeOrder(snCodes, consumeReasonBean.getDescription(), consumeQuantity);
} else {
//如果需要打印,則是在打印完之後查詢,如果不需要打印,現在就查詢刷新頁面
//消耗完之後,刷新列表
......@@ -258,9 +255,26 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
});
}
public void querySnCodeList(int foodQuantity, String remark, String warehousingOrderDetailsIds) {
/**
* 查詢sn碼記錄
*
* @param infoType 數據類型 0入庫流水SN碼,1出庫流水SN碼
* @param foodQuantity 數量
* @param remark 備註
* @param warehousingOrderDetailsIds
*/
public void querySnCodeList(int infoType, int foodQuantity, String remark, String warehousingOrderDetailsIds) {
Map<String, Object> map = new HashMap<>();
map.put("warehousingOrderDetailsIds", warehousingOrderDetailsIds);
//入库SN编码查询 statesSn 0
//出库SN编码查询 statesSn 1
map.put("statesSn", infoType);
if (infoType == 0) {
//入庫傳這個
map.put("warehousingEncodeSnIdList", warehousingOrderDetailsIds);
} else {
//出庫傳這個
map.put("consumeEncodeSnIdList", warehousingOrderDetailsIds);
}
mModel.querySnCodeList(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.QUERY_LOADING))
......@@ -279,4 +293,30 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
});
}
/**
* 查詢sn碼記錄
*
* @param infoType 數據類型 0入庫流水SN碼,1出庫流水SN碼
* @param foodQuantity 數量
* @param remark 備註
* @param warehousingOrderDetailsIds
*/
public void queryInStockSnCodes(int foodQuantity, String remark, String foodNo) {
mModel.queryInStockSnCodes(foodNo)
.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()) {
List<PurchaseFoodEncodeSn> purchaseFoodEncodeSns = GsonUtils.jsonToList(baseResult.getData(), PurchaseFoodEncodeSn.class);
mRootView.jumpSnList(foodQuantity, remark, purchaseFoodEncodeSns);
}
}
});
}
}
......@@ -284,9 +284,13 @@ public interface SupplierServer {
@Headers({"Domain-Name: ricepon-purchase"})
@GET("purchaseFood/purchaseFoodSnlist" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
@GET("purchaseFood/warehousingEncodeSnIdList" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> querySnCodes(@Query("encodeFoodNo") String encodeFoodNo, @Query("encodeOrderNo") String encodeOrderNo);
@Headers({"Domain-Name: ricepon-purchase"})
@GET("purchaseFood/deletesPurchaseFoodEncodeSn" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> deleteSnCode(@QueryMap Map<String, Object> map);
/**
* 再來一單,通過食材ids獲取詳細信息
*
......@@ -453,8 +457,21 @@ public interface SupplierServer {
@GET("purchaseConsume/get/remaining/quantity" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getWarehousingNum(@QueryMap Map<String, Object> map);
/**
* 查詢庫存的sn記錄
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("purchaseFood/foodEncodeDetailsSnList" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> queryInStockSnCodes(@Query("encodeFoodNo") String foodNo);
/**
* 查詢入庫流水或出庫流水的sn記錄
*
* @param map
* @return
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("purchaseFood/purchaseFoodSnlist" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
@GET("purchaseFood/outboundInventoryEncodeSnIdList" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> querySnCodeList(@QueryMap Map<String, Object> map);
/**
......
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.util.SparseArray;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.recyclerview.widget.RecyclerView;
/**
* 通用的RecyclerView.ViewHolder。提供了根据viewId获取View的方法。
* 提供了对View、TextView、ImageView的常用设置方法。
*/
public class BaseViewHolder extends RecyclerView.ViewHolder {
private SparseArray<View> mViews;
public BaseViewHolder(View itemView) {
super(itemView);
mViews = new SparseArray<>();
}
/**
* 获取item对应的ViewDataBinding对象
*
* @param <T>
* @return
*/
public <T extends ViewDataBinding> T getBinding() {
return DataBindingUtil.getBinding(this.itemView);
}
/**
* 根据View Id 获取对应的View
*
* @param viewId
* @param <T>
* @return
*/
public <T extends View> T get(int viewId) {
View view = mViews.get(viewId);
if (view == null) {
view = this.itemView.findViewById(viewId);
mViews.put(viewId, view);
}
return (T) view;
}
//******** 提供对View、TextView、ImageView的常用设置方法 ******//
public BaseViewHolder setText(int viewId, CharSequence text) {
TextView tv = get(viewId);
tv.setText(text);
return this;
}
public BaseViewHolder setText(int viewId, int textRes) {
TextView tv = get(viewId);
tv.setText(textRes);
return this;
}
public BaseViewHolder setTextColor(int viewId, int textColor) {
TextView view = get(viewId);
view.setTextColor(textColor);
return this;
}
public BaseViewHolder setTextSize(int viewId, float size) {
TextView view = get(viewId);
view.setTextSize(size);
return this;
}
public BaseViewHolder setImageResource(int viewId, int resId) {
ImageView view = get(viewId);
view.setImageResource(resId);
return this;
}
public BaseViewHolder setImageBitmap(int viewId, Bitmap bitmap) {
ImageView view = get(viewId);
view.setImageBitmap(bitmap);
return this;
}
public BaseViewHolder setImageDrawable(int viewId, Drawable drawable) {
ImageView view = get(viewId);
view.setImageDrawable(drawable);
return this;
}
public BaseViewHolder setBackgroundColor(int viewId, int color) {
View view = get(viewId);
view.setBackgroundColor(color);
return this;
}
public BaseViewHolder setBackgroundRes(int viewId, int backgroundRes) {
View view = get(viewId);
view.setBackgroundResource(backgroundRes);
return this;
}
public BaseViewHolder setVisible(int viewId, boolean visible) {
View view = get(viewId);
view.setVisibility(visible ? View.VISIBLE : View.GONE);
return this;
}
public BaseViewHolder setVisible(int viewId, int visible) {
View view = get(viewId);
view.setVisibility(visible);
return this;
}
}
......@@ -2,29 +2,18 @@ package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.text.Editable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import com.gingersoft.gsa.cloud.ui.view.section.QDSectionHeaderView;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.google.android.material.textfield.TextInputEditText;
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView;
import com.qmuiteam.qmui.layout.QMUIButton;
import com.qmuiteam.qmui.widget.section.QMUIDefaultStickySectionAdapter;
import com.qmuiteam.qmui.widget.section.QMUISection;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionAdapter;
import java.util.List;
......@@ -38,54 +27,80 @@ import butterknife.ButterKnife;
* Time: 16:18
* Use: 食材列表
*/
public class BuyIngredientsAdapter extends QMUIDefaultStickySectionAdapter<CategoryBean, PurchaseFoodBean> {
public class BuyIngredientsAdapter extends GroupedRecyclerViewAdapter {
private Context context;
private List<BuyIngredientsBean> buyIngredientsBeans;
private boolean isSinger = true;
public BuyIngredientsAdapter(Context context, List<QMUISection<CategoryBean, PurchaseFoodBean>> food) {
this.context = context;
setData(food);
public BuyIngredientsAdapter(Context context, List<BuyIngredientsBean> buyIngredientsBeans) {
super(context);
this.buyIngredientsBeans = buyIngredientsBeans;
}
public void setShowSingerRow(boolean showType) {
isSinger = showType;
}
/**
* 設置減少按鈕和輸入框的顯示或隱藏
*
* @param showOrHide 顯示或隱藏
*/
private void setSubAndNumShow(ItemViewHolder itemViewHolder, boolean showOrHide) {
itemViewHolder.btnFoodOperationSub.setVisibility(showOrHide ? View.GONE : View.VISIBLE);
itemViewHolder.edFoodIngredientNumber.setVisibility(showOrHide ? View.INVISIBLE : View.VISIBLE);
}
@NonNull
@Override
protected HeadViewHolder onCreateSectionHeaderViewHolder(@NonNull ViewGroup viewGroup) {
return new HeadViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_buy_food_ingredient_header, viewGroup, false));
public int getGroupCount() {
return buyIngredientsBeans == null ? 0 : buyIngredientsBeans.size();
}
public int getLayoutId() {
if (isSinger) {
return R.layout.item_buy_food_ingredient;
@Override
public int getChildrenCount(int groupPosition) {
BuyIngredientsBean buyIngredientsBean = buyIngredientsBeans.get(groupPosition);
return buyIngredientsBean.purchaseFoodList == null ? 0 : buyIngredientsBean.purchaseFoodList.size();
}
return R.layout.item_buy_food_ingredient_double_row;
@Override
public boolean hasHeader(int groupPosition) {
return true;
}
public void setShowSingerRow(boolean showType) {
isSinger = showType;
@Override
public boolean hasFooter(int groupPosition) {
return false;
}
@NonNull
@Override
protected ItemViewHolder onCreateSectionItemViewHolder(@NonNull ViewGroup viewGroup) {
return new ItemViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(getLayoutId(), viewGroup, false));
public int getHeaderLayout(int viewType) {
return R.layout.item_buy_food_ingredient_header;
}
@Override
public int getFooterLayout(int viewType) {
return 0;
}
@Override
protected void onBindSectionHeader(QMUIStickySectionAdapter.ViewHolder holder, int position, QMUISection<CategoryBean, PurchaseFoodBean> section) {
super.onBindSectionHeader(holder, position, section);
HeadViewHolder headViewHolder = (HeadViewHolder) holder;
headViewHolder.tvHeader.setText(section.getHeader().getCategoryName());
public int getChildLayout(int viewType) {
return getLayoutId();
}
@Override
protected void onBindSectionItem(QMUIStickySectionAdapter.ViewHolder holder, int position, QMUISection<CategoryBean, PurchaseFoodBean> section, int itemIndex) {
super.onBindSectionItem(holder, position, section, itemIndex);
ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
PurchaseFoodBean purchaseFoodBean = section.getItemList().get(itemIndex);
public void onBindHeaderViewHolder(BaseViewHolder holder, int groupPosition) {
holder.setText(R.id.tv_buy_food_header, buyIngredientsBeans.get(groupPosition).categoryName);
}
@Override
public void onBindFooterViewHolder(BaseViewHolder holder, int groupPosition) {
}
@Override
public void onBindChildViewHolder(BaseViewHolder holder, int groupPosition, int childPosition) {
ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
PurchaseFoodBean purchaseFoodBean = buyIngredientsBeans.get(groupPosition).purchaseFoodList.get(childPosition);
itemViewHolder.tvSupplierName.setText(purchaseFoodBean.getSupplierName());
itemViewHolder.ivFoodIngredientImg.setImageResource(R.drawable.img_small_default);
if (TextUtil.isNotEmptyOrNullOrUndefined(purchaseFoodBean.getImages())) {
......@@ -99,7 +114,7 @@ public class BuyIngredientsAdapter extends QMUIDefaultStickySectionAdapter<Categ
} else {
itemViewHolder.tvFoodItemUnit.setText(purchaseFoodBean.getBasicUnitName());
}
itemViewHolder.tvFoodItemPrice.setText(String.format(context.getString(R.string.amount_string), purchaseFoodBean.getUnitPrice()));
itemViewHolder.tvFoodItemPrice.setText(String.format(mContext.getString(R.string.amount_string), purchaseFoodBean.getUnitPrice()));
itemViewHolder.edFoodIngredientNumber.setText(String.valueOf(purchaseFoodBean.getFoodQuantity()), TextView.BufferType.EDITABLE);
//如果數量小於等於0,就不顯示減號和數量
......@@ -131,27 +146,19 @@ public class BuyIngredientsAdapter extends QMUIDefaultStickySectionAdapter<Categ
});
}
/**
* 設置減少按鈕和輸入框的顯示或隱藏
*
* @param showOrHide 顯示或隱藏
*/
private void setSubAndNumShow(ItemViewHolder itemViewHolder, boolean showOrHide) {
itemViewHolder.btnFoodOperationSub.setVisibility(showOrHide ? View.GONE : View.VISIBLE);
itemViewHolder.edFoodIngredientNumber.setVisibility(showOrHide ? View.INVISIBLE : View.VISIBLE);
public int getLayoutId() {
if (isSinger) {
return R.layout.item_buy_food_ingredient;
}
public static class HeadViewHolder extends QMUIStickySectionAdapter.ViewHolder {
@BindView(R2.id.tv_buy_food_header)
QMUIAlphaTextView tvHeader;
public HeadViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
return R.layout.item_buy_food_ingredient_double_row;
}
public void setData(List<BuyIngredientsBean> buyIngredientsBeans) {
this.buyIngredientsBeans = buyIngredientsBeans;
notifyDataSetChanged();
}
public static class ItemViewHolder extends QMUIStickySectionAdapter.ViewHolder {
public static class ItemViewHolder extends com.gingersoft.supply_chain.mvp.ui.adapter.BaseViewHolder {
@BindView(R2.id.iv_food_ingredient_img)
ImageView ivFoodIngredientImg;
@BindView(R2.id.tv_food_item_no)
......
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.text.Editable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import com.gingersoft.gsa.cloud.ui.view.section.QDSectionHeaderView;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.google.android.material.textfield.TextInputEditText;
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView;
import com.qmuiteam.qmui.layout.QMUIButton;
import com.qmuiteam.qmui.widget.section.QMUIDefaultStickySectionAdapter;
import com.qmuiteam.qmui.widget.section.QMUISection;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionAdapter;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* @author 宇航.
* User: admin
* Date: 2021/3/11
* Time: 16:18
* Use: 食材列表
*/
public class OldBuyIngredientsAdapter extends QMUIDefaultStickySectionAdapter<CategoryBean, PurchaseFoodBean> {
private Context context;
private boolean isSinger = true;
public OldBuyIngredientsAdapter(Context context, List<QMUISection<CategoryBean, PurchaseFoodBean>> food) {
this.context = context;
setData(food);
}
@NonNull
@Override
protected HeadViewHolder onCreateSectionHeaderViewHolder(@NonNull ViewGroup viewGroup) {
return new HeadViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_buy_food_ingredient_header, viewGroup, false));
}
public int getLayoutId() {
if (isSinger) {
return R.layout.item_buy_food_ingredient;
}
return R.layout.item_buy_food_ingredient_double_row;
}
public void setShowSingerRow(boolean showType) {
isSinger = showType;
}
@NonNull
@Override
protected ItemViewHolder onCreateSectionItemViewHolder(@NonNull ViewGroup viewGroup) {
return new ItemViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(getLayoutId(), viewGroup, false));
}
@Override
protected void onBindSectionHeader(QMUIStickySectionAdapter.ViewHolder holder, int position, QMUISection<CategoryBean, PurchaseFoodBean> section) {
super.onBindSectionHeader(holder, position, section);
HeadViewHolder headViewHolder = (HeadViewHolder) holder;
headViewHolder.tvHeader.setText(section.getHeader().getCategoryName());
}
@Override
protected void onBindSectionItem(QMUIStickySectionAdapter.ViewHolder holder, int position, QMUISection<CategoryBean, PurchaseFoodBean> section, int itemIndex) {
super.onBindSectionItem(holder, position, section, itemIndex);
ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
PurchaseFoodBean purchaseFoodBean = section.getItemList().get(itemIndex);
itemViewHolder.tvSupplierName.setText(purchaseFoodBean.getSupplierName());
itemViewHolder.ivFoodIngredientImg.setImageResource(R.drawable.img_small_default);
if (TextUtil.isNotEmptyOrNullOrUndefined(purchaseFoodBean.getImages())) {
GlideUtils.display(itemViewHolder.ivFoodIngredientImg.getContext(), itemViewHolder.ivFoodIngredientImg, purchaseFoodBean.getImages());
}
itemViewHolder.tvFoodItemNo.setText(purchaseFoodBean.getFoodNo());
itemViewHolder.tvFoodItemName.setText(purchaseFoodBean.getName());
//如果有包裝描述就顯示包裝描述,沒有包裝描述顯示基本單位
if (TextUtil.isNotEmptyOrNullOrUndefined(purchaseFoodBean.getPackingDescription())) {
itemViewHolder.tvFoodItemUnit.setText(purchaseFoodBean.getPackingDescription());
} else {
itemViewHolder.tvFoodItemUnit.setText(purchaseFoodBean.getBasicUnitName());
}
itemViewHolder.tvFoodItemPrice.setText(String.format(context.getString(R.string.amount_string), purchaseFoodBean.getUnitPrice()));
itemViewHolder.edFoodIngredientNumber.setText(String.valueOf(purchaseFoodBean.getFoodQuantity()), TextView.BufferType.EDITABLE);
//如果數量小於等於0,就不顯示減號和數量
setSubAndNumShow(itemViewHolder, purchaseFoodBean.getFoodQuantity() <= 0);
//編輯數量
itemViewHolder.btnFoodOperationSub.setOnClickListener(v -> {
//食材數量減少
if (purchaseFoodBean.getFoodQuantity() > 0) {
purchaseFoodBean.setFoodQuantity(purchaseFoodBean.getFoodQuantity() - 1);
itemViewHolder.edFoodIngredientNumber.setText(String.valueOf(purchaseFoodBean.getFoodQuantity()));
}
setSubAndNumShow(itemViewHolder, purchaseFoodBean.getFoodQuantity() <= 0);
});
itemViewHolder.btnFoodOperationAdd.setOnClickListener(v -> {
//食材數量增加
purchaseFoodBean.setFoodQuantity(purchaseFoodBean.getFoodQuantity() + 1);
itemViewHolder.edFoodIngredientNumber.setText(String.valueOf(purchaseFoodBean.getFoodQuantity()));
setSubAndNumShow(itemViewHolder, false);
});
//輸入框焦點監聽
itemViewHolder.edFoodIngredientNumber.setOnFocusChangeListener((v, hasFocus) -> {
Editable text = itemViewHolder.edFoodIngredientNumber.getText();
if (!hasFocus) {
//當失去焦點時,如果沒有食品數量了,就隱藏減號和輸入框
if (TextUtil.isEmptyOrNullOrUndefined(text) || Integer.parseInt(text.toString()) == 0) {
setSubAndNumShow(itemViewHolder, false);
}
}
});
}
/**
* 設置減少按鈕和輸入框的顯示或隱藏
*
* @param showOrHide 顯示或隱藏
*/
private void setSubAndNumShow(ItemViewHolder itemViewHolder, boolean showOrHide) {
itemViewHolder.btnFoodOperationSub.setVisibility(showOrHide ? View.GONE : View.VISIBLE);
itemViewHolder.edFoodIngredientNumber.setVisibility(showOrHide ? View.INVISIBLE : View.VISIBLE);
}
public static class HeadViewHolder extends QMUIStickySectionAdapter.ViewHolder {
@BindView(R2.id.tv_buy_food_header)
QMUIAlphaTextView tvHeader;
public HeadViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
}
public static class ItemViewHolder extends QMUIStickySectionAdapter.ViewHolder {
@BindView(R2.id.iv_food_ingredient_img)
ImageView ivFoodIngredientImg;
@BindView(R2.id.tv_food_item_no)
TextView tvFoodItemNo;
@BindView(R2.id.tv_food_item_supplier_name)
TextView tvSupplierName;
@BindView(R2.id.tv_food_item_name)
TextView tvFoodItemName;
@BindView(R2.id.tv_food_item_unit)
TextView tvFoodItemUnit;
@BindView(R2.id.tv_food_item_price)
TextView tvFoodItemPrice;
@BindView(R2.id.btn_food_operation_sub)
QMUIButton btnFoodOperationSub;
@BindView(R2.id.ed_food_ingredient_number)
TextInputEditText edFoodIngredientNumber;
@BindView(R2.id.btn_food_operation_add)
QMUIButton btnFoodOperationAdd;
public ItemViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
}
}
......@@ -35,7 +35,7 @@ public class SnCodesAdapter extends BaseQuickAdapter<PurchaseFoodEncodeSn, BaseV
viewHolder.setBackgroundColor(R.id.layout_sn_item, colorRes);
setTextColor(viewHolder, getColor(getContext(), R.color.color_3c));
viewHolder.setText(R.id.tv_serial_number, String.valueOf(viewHolder.getAdapterPosition()));
viewHolder.setText(R.id.tv_serial_number, String.valueOf(viewHolder.getAdapterPosition() +1));
viewHolder.setText(R.id.tv_sn_code, String.valueOf(purchaseFoodEncodeSn.getEncodeSnNo()));
viewHolder.setText(R.id.tv_operator, String.valueOf(purchaseFoodEncodeSn.userName));
viewHolder.setText(R.id.tv_time, TimeUtils.getStringByFormat(purchaseFoodEncodeSn.updateTime, TimeUtils.DATE_FORMAT_DATE));
......
......@@ -106,8 +106,7 @@ public class SendMsgFragment extends BaseSupplyChainFragment<SendMsgPresenter> i
//發送
mPresenter.sendMsg();
} else if (viewId == R.id.btn_supplier_cancel) {
// popTo(PurchaseListFragment.class, true);
killMyself();
backToOrderList();
} else if (viewId == R.id.qmui_preview) {
//預覽
String sendUrl = mPresenter.getSendUrl();
......@@ -163,16 +162,26 @@ public class SendMsgFragment extends BaseSupplyChainFragment<SendMsgPresenter> i
@Override
public void backToOrderList() {
startWithPopTo(PurchaseListFragment.newInstance(), PurchaseListFragment.class, true);
List<Fragment> fragments = requireActivity().getSupportFragmentManager().getFragments();
for (Fragment fragment : fragments) {
if (fragment instanceof PurchaseListFragment) {
//有訂單列表
popTo(PurchaseListFragment.class, false);
return;
}
}
//沒有訂單列表
startWithPop(PurchaseListFragment.newInstance());
// startWithPopTo(PurchaseListFragment.newInstance(), this, false);
}
private boolean isSend = false;
@Override
public void killMyself() {
backToOrderList();
}
private boolean isSend = false;
@Override
public void onResume() {
super.onResume();
......
package com.gingersoft.supply_chain.mvp.ui.widget;
import android.content.Context;
import android.util.AttributeSet;
import androidx.recyclerview.widget.GridLayoutManager;
import com.gingersoft.supply_chain.mvp.ui.adapter.GroupedRecyclerViewAdapter;
/**
* 为分组列表提供的GridLayoutManager。
* 因为分组列表如果要使用GridLayoutManager实现网格布局。要保证组的头部和尾部是要单独占用一行的。
* 否则组的头、尾可能会跟子项混着一起,造成布局混乱。
*/
public class GroupedGridLayoutManager extends GridLayoutManager {
private GroupedRecyclerViewAdapter mAdapter;
public GroupedGridLayoutManager(Context context, int spanCount,
GroupedRecyclerViewAdapter adapter) {
super(context, spanCount);
mAdapter = adapter;
setSpanSizeLookup();
}
public GroupedGridLayoutManager(Context context, int spanCount, int orientation,
boolean reverseLayout, GroupedRecyclerViewAdapter adapter) {
super(context, spanCount, orientation, reverseLayout);
this.mAdapter = adapter;
setSpanSizeLookup();
}
public GroupedGridLayoutManager(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes, GroupedRecyclerViewAdapter adapter) {
super(context, attrs, defStyleAttr, defStyleRes);
this.mAdapter = adapter;
setSpanSizeLookup();
}
private void setSpanSizeLookup() {
super.setSpanSizeLookup(new SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
int count = getSpanCount();
if (mAdapter != null) {
int type = mAdapter.judgeType(position);
//只对子项做Grid效果
if (type == GroupedRecyclerViewAdapter.TYPE_CHILD) {
int groupPosition = mAdapter.getGroupPositionForPosition(position);
int childPosition =
mAdapter.getChildPositionForPosition(groupPosition, position);
return getChildSpanSize(groupPosition, childPosition);
}
}
return count;
}
});
}
/**
* 提供这个方法可以使外部改变子项的SpanSize。
* 这个方法的作用跟{@link SpanSizeLookup#getSpanSize(int)}一样。
* @param groupPosition
* @param childPosition
* @return
*/
public int getChildSpanSize(int groupPosition, int childPosition) {
return 1;
}
@Override
public void setSpanSizeLookup(SpanSizeLookup spanSizeLookup) {
}
}
\ No newline at end of file
......@@ -57,6 +57,7 @@ public class InventoryConsumptionView extends FrameLayout {
private OnConfirmClickListener onConfirmClickListener;
private ScanSnView.OnCancelListener onCancelListener;
private ConsumptionReasonAdapter consumptionReasonAdapter;
private OnNumberChangeListener onNumberChangeListener;
public InventoryConsumptionView(@NonNull Context context, List<ConsumeReasonBean> consumeReasonBeans, int maxConsumption) {
super(context);
......@@ -110,6 +111,9 @@ public class InventoryConsumptionView extends FrameLayout {
if (i > maxConsumption) {
edInput.setError("不能超過當前庫存數量:" + maxConsumption);
}
if (onNumberChangeListener != null) {
onNumberChangeListener.onNumberChange(i);
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
......@@ -132,6 +136,11 @@ public class InventoryConsumptionView extends FrameLayout {
return this;
}
public InventoryConsumptionView setOnNumberChangeListener(OnNumberChangeListener onNumberChangeListener) {
this.onNumberChangeListener = onNumberChangeListener;
return this;
}
public String getRemark() {
return edRemarks.getText().toString();
}
......@@ -150,11 +159,11 @@ public class InventoryConsumptionView extends FrameLayout {
}
/**
* 獲取消耗數量
* 獲取消耗數量並提示
*
* @return 輸入的數量
*/
public int getConsumptionNum() {
public int getConsumptionNumAndTip() {
String s = edInput.getText().toString();
try {
int i = Integer.parseInt(s);
......@@ -178,6 +187,20 @@ public class InventoryConsumptionView extends FrameLayout {
}
}
/**
* 獲取消耗數量
*
* @return 輸入的數量
*/
public int getConsumptionNum() {
String s = edInput.getText().toString();
try {
return Integer.parseInt(s);
} catch (NumberFormatException e) {
return -1;
}
}
public void setConsumptionNumber(int consumptionNumber) {
edInput.setText(String.valueOf(consumptionNumber));
}
......@@ -192,4 +215,8 @@ public class InventoryConsumptionView extends FrameLayout {
*/
void onConfirm(int consumptionNum, int reasonIndex, String remarks);
}
public interface OnNumberChangeListener {
void onNumberChange(int num);
}
}
......@@ -2,6 +2,7 @@ package com.gingersoft.supply_chain.mvp.ui.widget;
import android.annotation.SuppressLint;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import androidx.annotation.NonNull;
......@@ -9,6 +10,7 @@ import androidx.fragment.app.Fragment;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodEncodeSn;
import com.jess.arms.utils.DeviceUtils;
import com.lxj.xpopup.core.BottomPopupView;
......@@ -28,8 +30,9 @@ import butterknife.ButterKnife;
public class ScanSnPopup extends BottomPopupView {
private final String foodName;
private final List<String> snCodes;
private final List<PurchaseFoodEncodeSn> snCodes;
private final Fragment fragment;
private final boolean operable;
@BindView(R2.id.tv_food_Ingredients_name)
TextView tvFoodIngredientsName;
@BindView(R2.id.tv_food_inbound_quantity)
......@@ -37,15 +40,26 @@ public class ScanSnPopup extends BottomPopupView {
@BindView(R2.id.layout_scan_sn)
LinearLayout rootLayout;
private OnScanResultListener onScanResultListener;
private PopupWindow.OnDismissListener onDismissListener;
private ScanSnView.OnDeleteSnCodeListener onDeleteListener;
/**
* 最大掃碼數量
*/
private int maxCodeSize = -1;
/**
* 最少掃碼數量
*/
private int minCodeSize = 0;
public ScanSnPopup(@NonNull Fragment fragment, String foodName, List<String> snCodes) {
public ScanSnPopup(@NonNull Fragment fragment, String foodName, List<PurchaseFoodEncodeSn> purchaseFoodEncodeSns, boolean operable) {
super(fragment.requireContext());
if (snCodes == null) {
snCodes = new ArrayList<>();
if (purchaseFoodEncodeSns == null) {
purchaseFoodEncodeSns = new ArrayList<>();
}
this.foodName = foodName;
this.snCodes = snCodes;
this.snCodes = purchaseFoodEncodeSns;
this.fragment = fragment;
this.operable = operable;
addInnerContent();
}
......@@ -66,28 +80,66 @@ public class ScanSnPopup extends BottomPopupView {
ButterKnife.bind(this);
tvFoodIngredientsName.setText(foodName);
tvFoodInboundQuantity.setText(String.valueOf(snCodes.size()));
rootLayout.addView(new ScanSnView(fragment, snCodes, (isAdd, snCode, currentSnCodeNumber) -> {
if (operable) {
rootLayout.addView(new ScanSnView(fragment, snCodes, (popup, scanResult) -> onScanResultListener.onScanResult(ScanSnPopup.this, scanResult))
.setOnDeleteSnCodeListener(onDeleteListener)
.setOnCancelListener(this::dismiss)
.setMinCodeSize(minCodeSize)
.setMaxCodeSize(maxCodeSize)
.setOnSingerResultListener((isAdd, snCode, currentSnCodeNumber) -> {
//每掃描出一個調用
tvFoodInboundQuantity.setText(String.valueOf(currentSnCodeNumber));
}, onScanResultListener).setOnCancelListener(this::dismiss), new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
}).init()
, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
} else {
rootLayout.addView(new ShowSnView(getContext(), snCodes));
}
}
@Override
protected int getMaxHeight() {
return (int) (DeviceUtils.getScreenHeight(getContext()) / 2);
public ScanSnPopup setMaxCodeSize(int maxCodeSize) {
this.maxCodeSize = maxCodeSize;
return this;
}
public ScanSnPopup setMinCodeSize(int minCodeSize) {
this.minCodeSize = minCodeSize;
return this;
}
@Override
protected int getPopupHeight() {
protected int getMaxHeight() {
return (int) (DeviceUtils.getScreenHeight(getContext()) / 2);
}
// @Override
// protected int getPopupHeight() {
// return (int) (DeviceUtils.getScreenHeight(getContext()) / 2);
// }
public interface OnScanResultListener {
/**
* 掃完碼確認之後回調
*
* @param scanResult 本次掃碼結果
*/
void onScanResult(List<String> scanResult);
void onScanResult(ScanSnPopup popup, List<PurchaseFoodEncodeSn> scanResult);
}
public ScanSnPopup setOnDeleteListener(ScanSnView.OnDeleteSnCodeListener onDeleteListener) {
this.onDeleteListener = onDeleteListener;
return this;
}
public ScanSnPopup setOnDismissListener(PopupWindow.OnDismissListener onDismissListener) {
this.onDismissListener = onDismissListener;
return this;
}
@Override
protected void onDismiss() {
super.onDismiss();
if (onDismissListener != null) {
onDismissListener.onDismiss();
}
}
}
package com.gingersoft.supply_chain.mvp.ui.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.FrameLayout;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
import com.billy.cc.core.component.CC;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.XPermissionUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.component.ComponentName;
import com.gingersoft.gsa.cloud.ui.utils.AppDialog;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodEncodeSn;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.qmuiteam.qmui.alpha.QMUIAlphaImageButton;
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import cn.bingoogolapple.qrcode.core.BarcodeType;
import me.yokeyword.fragmentation.SupportHelper;
/**
* @author 宇航.
* User: admin
* Date: 2021/3/18
* Time: 17:23
* Use: 掃描sn碼
*/
public class ShowSnView extends FrameLayout {
private List<PurchaseFoodEncodeSn> snCodes;
@BindView(R2.id.rv_sn_code)
RecyclerView rvSnCode;
public ShowSnView(Context context, List<PurchaseFoodEncodeSn> snCodes) {
super(context);
this.snCodes = snCodes;
init();
}
private void init() {
View rootView = LayoutInflater.from(getContext()).inflate(R.layout.layout_show_sn, this, false);
ButterKnife.bind(this, rootView);
//初始化adapter
ScanSnView.SnCodeAdapter adapter = new ScanSnView.SnCodeAdapter(R.layout.item_show_sn_code, snCodes);
rvSnCode.setAdapter(adapter);
addView(rootView);
}
}
......@@ -172,19 +172,20 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout
android:id="@+id/section_food_ingredients"
<com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent">
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_food_ingredients"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_5"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<!-- <androidx.recyclerview.widget.RecyclerView-->
<!-- android:id="@+id/rv_food_ingredients"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_marginTop="@dimen/dp_5"-->
<!-- app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />-->
</com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
......
......@@ -150,12 +150,6 @@
app:srlEnablePreviewInEditMode="true"
app:srlPrimaryColor="@color/trans">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<!-- scrollview在代碼中要添加多個子view,所以多用一個LinearLayout包裹起來-->
<LinearLayout
android:id="@+id/layout_warehousing_root"
android:layout_width="match_parent"
......@@ -170,8 +164,5 @@
android:layout_marginTop="@dimen/dp_10"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_sn_code"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_38"
android:background="@color/theme_color"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_serial_number"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.21"
android:gravity="center"
android:text="@string/str_serial_number"
android:textColor="@color/white" />
<include layout="@layout/include_vertical_color_e8_dividing_line" />
<TextView
android:id="@+id/tv_sn_code"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.55"
android:gravity="center"
android:text="@string/str_sn_code"
android:textColor="@color/white" />
<include layout="@layout/include_vertical_color_e8_dividing_line" />
<FrameLayout
android:layout_width="@dimen/dp_0"
android:layout_height="match_parent"
android:layout_weight="0.24"
android:visibility="gone">
<ImageView
android:id="@+id/iv_sn_code_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_delete"
android:visibility="gone" />
<TextView
android:id="@+id/it_sn_code_operating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/str_operating"
android:textColor="@color/white" />
</FrameLayout>
</LinearLayout>
\ No newline at end of file
......@@ -66,4 +66,15 @@
android:text="製單人:"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14" />
<TextView
android:id="@+id/tv_print_sn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginLeft="@dimen/dp_5"
android:text="@string/str_sn_codes"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14" />
</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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/item_show_sn_code" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_sn_code"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
</LinearLayout>
\ No newline at end of file
......@@ -33,5 +33,5 @@
<string name="str_no">NO:%1$s</string>
<string name="str_prepared">製單人:%1$s</string>
<string name="str_device_not_print">您的設備不支持打印</string>
<string name="str_sn_codes">SN嗎:%1$s</string>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="type_header" type="integer"/>
<item name="type_footer" type="integer"/>
<item name="type_child" type="integer"/>
<item name="type_empty" type="integer"/>
</resources>
\ No newline at end of file
......@@ -28,28 +28,39 @@ public class CollectionUtils {
}
/**
* 判断集合是否为null或者0个元素
*
* @param c
* @return
*/
public static boolean isNotNullOrEmpty(Collection c) {
return !(null == c || c.isEmpty());
}
/**
* 调换集合中两个指定位置的元素, 若两个元素位置中间还有其他元素,需要实现中间元素的前移或后移的操作。
*
* @param list 集合
* @param oldPosition 需要调换的元素
* @param newPosition 被调换的元素
* @param <T>
*/
public static <T> void swap1(List<T> list, int oldPosition, int newPosition){
if(null == list){
public static <T> void swap1(List<T> list, int oldPosition, int newPosition) {
if (null == list) {
throw new IllegalStateException("The list can not be empty...");
}
T tempElement = list.get(oldPosition);
// 向前移动,前面的元素需要向后移动
if(oldPosition < newPosition){
for(int i = oldPosition; i < newPosition; i++){
if (oldPosition < newPosition) {
for (int i = oldPosition; i < newPosition; i++) {
list.set(i, list.get(i + 1));
}
list.set(newPosition, tempElement);
}
// 向后移动,后面的元素需要向前移动
if(oldPosition > newPosition){
for(int i = oldPosition; i > newPosition; i--){
if (oldPosition > newPosition) {
for (int i = oldPosition; i > newPosition; i--) {
list.set(i, list.get(i - 1));
}
list.set(newPosition, tempElement);
......@@ -58,6 +69,7 @@ public class CollectionUtils {
/**
* 调换集合中两个指定位置的元素, 若两个元素位置中间还有其他元素,需要实现中间元素的前移或后移的操作。
*
* @param list 集合
* @param oldPosition 需要调换的元素
* @param newPosition 被调换的元素
......@@ -85,6 +97,7 @@ public class CollectionUtils {
/**
* 深拷貝一個list集合,改變當前集合不影響之前的集合數據
*
* @param src
* @param <E>
* @return
......@@ -108,6 +121,7 @@ public class CollectionUtils {
/**
* 过滤List中为null的元素
*
* @param oldList
* @param <T>
* @return
......@@ -115,7 +129,7 @@ public class CollectionUtils {
public static <T> List<T> removeNull(List<? extends T> oldList) {
// 临时集合
List<T> listTemp = new ArrayList();
for (int i = 0;i < oldList.size(); i++) {
for (int i = 0; i < oldList.size(); i++) {
// 保存不为空的元素
if (oldList.get(i) != null) {
listTemp.add(oldList.get(i));
......@@ -123,4 +137,21 @@ public class CollectionUtils {
}
return listTemp;
}
/**
* 将list转换为带有,逗號的字符串
*/
public static String listToCommaString(List<String> list) {
StringBuilder sb = new StringBuilder();
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
if (i < list.size() - 1) {
sb.append(list.get(i) + ",");
} else {
sb.append(list.get(i));
}
}
}
return sb.toString();
}
}
......@@ -70,6 +70,8 @@ public class PrinterDeviceBean implements Serializable {
private int foodIsBold;//食品是否加粗 0預設 1是 2否
public final static String DEFAULT_FONT_SIZE = "0";
public final static String PRESET = "預設";
private String foodFont;//食品字體大小 0預設
private int foodIsItalic;//食品是否斜體 0預設 1是 2否
......
......@@ -45,7 +45,7 @@
<TextView
android:id="@+id/tv_food_time"
style="@style/Print_eighteen_text"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
......@@ -64,14 +64,14 @@
<TextView
android:id="@+id/tv_order_time_text"
style="@style/Print_eighteen_text"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="落單:" />
<TextView
android:id="@+id/tv_order_time"
style="@style/Print_eighteen_text"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="01-04 19:32" />
......@@ -88,14 +88,14 @@
<TextView
android:id="@+id/tv_opening_time_text"
style="@style/Print_eighteen_text"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="開檯:" />
<TextView
android:id="@+id/tv_opening_time"
style="@style/Print_eighteen_text"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="01-20 12:00" />
......@@ -113,7 +113,7 @@
<TextView
android:id="@+id/tv_people_text"
style="@style/Print_eighteen_text"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="人數:"
......@@ -121,7 +121,7 @@
<TextView
android:id="@+id/tv_people"
style="@style/Print_eighteen_text"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
......@@ -129,7 +129,7 @@
<TextView
android:id="@+id/tv_kitchen_location_text"
style="@style/Print_eighteen_text"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
......@@ -138,7 +138,7 @@
<TextView
android:id="@+id/tv_kitchen_location"
style="@style/Print_eighteen_text"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
......@@ -156,7 +156,7 @@
<TextView
android:id="@+id/tv_order_num_text"
style="@style/Print_eighteen_text"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="單號:" />
......@@ -208,14 +208,14 @@
<TextView
android:id="@+id/tv_waiter_text"
style="@style/Print_eighteen_text"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="服務員:" />
<TextView
android:id="@+id/tv_waiter"
style="@style/Print_eighteen_text"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GSPOS" />
......
......@@ -35,6 +35,7 @@
<item name="android:includeFontPadding">false</item>
</style>
<style name="Print_thermal_printing_normal" parent="@style/Print_twenty_four_text" />
<style name="Print_dot_matrix_normal" parent="@style/Print_twenty_six_text" />
</resources>
\ No newline at end of file
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