Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
supplier
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王宇航
supplier
Commits
c6007590
Commit
c6007590
authored
Jul 26, 2021
by
张建升
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
綁定食材 代码同步
parent
299c86a6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
117 additions
and
29 deletions
+117
-29
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/DishDetailBean.java
+11
-8
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/contract/DishesContract.java
+3
-2
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/model/DishesModel.java
+4
-2
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/presenter/DishesPresenter.java
+45
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/server/SupplierServer.java
+2
-5
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/fragment/DishesFragment.java
+52
-12
No files found.
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/DishDetailBean.java
View file @
c6007590
package
com
.
gingersoft
.
supply_chain
.
mvp
.
bean
;
import
com.gingersoft.gsa.cloud.common.constans.AppConstant
;
import
com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishNode
;
import
java.util.List
;
import
lombok.Data
;
...
...
@@ -22,13 +25,14 @@ public class DishDetailBean {
private
String
foodBasicUnit
;
// string 非必须 食材基本单位
private
List
<
DeputyUnitBean
>
foodUnits
;
public
DishDetailBean
(
PurchaseFoodBean
foodBean
)
{
// this.id = foodBean.get;
// this.biFoodId = foodBean.getId();
// this.dishesName = dishesName;
// this.brandId = brandId;
// this.restaurantId = restaurantId;
// this.deletes = deletes;
public
DishDetailBean
(
PurchaseFoodBean
foodBean
,
DishNode
dishNode
)
{
// this.id = foodBean.get; ///此时的 id 一定是null deletes必是f
this
.
deletes
=
false
;
this
.
foodBasicUnit
=
foodBean
.
getBasicUnitName
();
this
.
biFoodId
=
dishNode
.
getId
();
this
.
dishesName
=
dishNode
.
getFoodName
();
this
.
brandId
=
AppConstant
.
getBrandId
();
this
.
restaurantId
=
AppConstant
.
getRestaurantId
();
this
.
purchaseFoodId
=
foodBean
.
getId
();;
this
.
foodName
=
foodBean
.
getName
();
this
.
consumeQuantity
=
foodBean
.
getFoodQuantity
();
...
...
@@ -36,6 +40,5 @@ public class DishDetailBean {
this
.
foodNo
=
foodBean
.
getFoodNo
();
this
.
type
=
0
;
this
.
foodUnits
=
foodBean
.
getFoodUnits
();
// this.foodBasicUnit = foodBean.getShowUnit().; ????
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/contract/DishesContract.java
View file @
c6007590
...
...
@@ -2,7 +2,6 @@ package com.gingersoft.supply_chain.mvp.contract;
import
com.gingersoft.gsa.cloud.common.bean.BaseResult
;
import
com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean
;
import
com.gingersoft.supply_chain.mvp.bean.DishDetailBean
;
import
com.gingersoft.supply_chain.mvp.bean.DishDetailResultBean
;
import
com.gingersoft.supply_chain.mvp.bean.DishesResultBean
;
import
com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishNode
;
...
...
@@ -14,6 +13,7 @@ import java.util.List;
import
java.util.Map
;
import
io.reactivex.Observable
;
import
okhttp3.RequestBody
;
/**
*
...
...
@@ -51,7 +51,7 @@ public interface DishesContract {
Observable
<
DishDetailResultBean
>
getDishesDetailData
(
Map
<
String
,
Object
>
map
);
Observable
<
String
>
bindDishes
(
Map
<
String
,
Object
>
map
);
Observable
<
BaseResult
>
bindDishes
(
RequestBody
requestBody
);
}
}
\ No newline at end of file
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/model/DishesModel.java
View file @
c6007590
...
...
@@ -19,6 +19,7 @@ import com.gingersoft.supply_chain.mvp.contract.DishesContract;
import
java.util.Map
;
import
io.reactivex.Observable
;
import
okhttp3.RequestBody
;
/**
*/
...
...
@@ -55,7 +56,7 @@ public class DishesModel extends BaseModel implements DishesContract.Model {
@Override
public
Observable
<
String
>
bindDishes
(
Map
<
String
,
Object
>
map
)
{
return
mRepositoryManager
.
obtainRetrofitService
(
SupplierServer
.
class
).
bindFoods
(
map
);
public
Observable
<
BaseResult
>
bindDishes
(
RequestBody
requestBody
)
{
return
mRepositoryManager
.
obtainRetrofitService
(
SupplierServer
.
class
).
bindFoods
(
requestBody
);
}
}
\ No newline at end of file
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/presenter/DishesPresenter.java
View file @
c6007590
...
...
@@ -2,9 +2,12 @@ package com.gingersoft.supply_chain.mvp.presenter;
import
android.app.Application
;
import
com.gingersoft.gsa.cloud.common.bean.BaseResult
;
import
com.gingersoft.gsa.cloud.common.constans.AppConstant
;
import
com.gingersoft.gsa.cloud.common.utils.JsonUtils
;
import
com.gingersoft.gsa.cloud.common.utils.log.LogUtil
;
import
com.gingersoft.gsa.cloud.common.utils.other.TextUtil
;
import
com.gingersoft.supply_chain.mvp.bean.DishDetailBean
;
import
com.gingersoft.supply_chain.mvp.bean.DishDetailResultBean
;
import
com.gingersoft.supply_chain.mvp.bean.DishesResultBean
;
import
com.gingersoft.supply_chain.mvp.contract.DishesContract
;
...
...
@@ -16,6 +19,8 @@ import com.jess.arms.integration.AppManager;
import
com.jess.arms.mvp.BasePresenter
;
import
com.jess.arms.utils.RxLifecycleUtils
;
import
org.jetbrains.annotations.NotNull
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -26,6 +31,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import
io.reactivex.schedulers.Schedulers
;
import
me.jessyan.rxerrorhandler.core.RxErrorHandler
;
import
me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber
;
import
okhttp3.MediaType
;
import
okhttp3.RequestBody
;
/**
* ================================================
...
...
@@ -85,6 +92,19 @@ public class DishesPresenter extends BasePresenter<DishesContract.Model, DishesC
mRootView
.
loadDishGroupFail
();
}
}
@Override
public
void
onComplete
()
{
super
.
onComplete
();
LogUtil
.
e
(
"ZJS"
,
" onComplete "
);
}
@Override
public
void
onError
(
@NotNull
Throwable
t
)
{
super
.
onError
(
t
);
mRootView
.
loadDishGroupFail
();
LogUtil
.
e
(
"ZJS"
,
" onError "
);
}
});
}
...
...
@@ -119,4 +139,28 @@ public class DishesPresenter extends BasePresenter<DishesContract.Model, DishesC
});
}
public
void
bindDishFoods
(
List
<
DishDetailBean
>
dishDetailBeans
)
{
mModel
.
bindDishes
(
RequestBody
.
create
(
MediaType
.
parse
(
"application/json"
),
JsonUtils
.
toJson
(
dishDetailBeans
)))
//發送請求
.
subscribeOn
(
Schedulers
.
io
())
//切換到io異步線程
.
doOnSubscribe
(
disposable
->
mRootView
.
showLoading
(
AppConstant
.
GET_INFO_LOADING
))
//顯示加載提示框
.
subscribeOn
(
AndroidSchedulers
.
mainThread
())
//切換到主線程,上面的提示框就在主線程
.
observeOn
(
AndroidSchedulers
.
mainThread
())
//切換到主線程,隱藏提示框在主線程
.
doAfterTerminate
(()
->
mRootView
.
hideLoading
())
//任務執行完成後,隱藏提示框
.
compose
(
RxLifecycleUtils
.
bindToLifecycle
(
mRootView
))
//綁定生命週期,頁面隱藏時斷開請求
.
observeOn
(
AndroidSchedulers
.
mainThread
())
//切換到主線程
.
subscribe
(
new
ErrorHandleSubscriber
<
BaseResult
>(
mErrorHandler
)
{
//mErrorHandler是統一的錯誤處理
@Override
public
void
onNext
(
BaseResult
bindResult
)
{
//數據處理
if
(
bindResult
.
isSuccess
())
{
LogUtil
.
e
(
"ZJS"
,
" 菜品食材綁定成功 bindResult"
+
bindResult
.
toString
());
mRootView
.
showMessage
(
"菜品食材綁定成功"
);
}
else
if
(
TextUtil
.
isNotEmptyOrNullOrUndefined
(
bindResult
.
getErrMsg
()))
{
mRootView
.
showMessage
(
bindResult
.
getErrMsg
());
}
else
{
mRootView
.
showMessage
(
AppConstant
.
GET_INFO_ERROR
);
}
}
});
}
}
\ No newline at end of file
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/server/SupplierServer.java
View file @
c6007590
...
...
@@ -572,12 +572,9 @@ public interface SupplierServer {
/**
* 菜品綁定食材
*
*/
@Headers
({
"Domain-Name: ricepon-purchase"
})
@GET
(
"purchaseDishesConversion/addPurchaseDishesConversion"
+
RetrofitUrlManager
.
IDENTIFICATION_PATH_SIZE
+
2
)
Observable
<
String
>
bindFoods
(
@QueryMap
Map
<
String
,
Object
>
map
);
@POST
(
"purchaseDishesConversion/addPurchaseDishesConversion"
+
RetrofitUrlManager
.
IDENTIFICATION_PATH_SIZE
+
2
)
Observable
<
BaseResult
>
bindFoods
(
@Body
RequestBody
requestBody
);
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/fragment/DishesFragment.java
View file @
c6007590
...
...
@@ -4,6 +4,8 @@ import android.os.Bundle;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewParent
;
import
android.widget.LinearLayout
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
...
...
@@ -11,6 +13,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.chad.library.adapter.base.entity.node.BaseNode
;
import
com.gingersoft.gsa.cloud.common.constans.AppConstant
;
import
com.gingersoft.gsa.cloud.common.utils.CollectionUtils
;
import
com.gingersoft.gsa.cloud.common.utils.log.LogUtil
;
import
com.gingersoft.supply_chain.R
;
...
...
@@ -52,9 +55,11 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp
RecyclerView
rvDishesGroup
;
@BindView
(
R2
.
id
.
rv_dishes_food
)
RecyclerView
rvDishes
;
private
View
footView
;
private
DishesTreeAdapter
dishesTreeAdapter
;
private
DishDetailAdapter
dishDetailAdapter
;
public
static
final
int
DISHES_ADD
=
123
;
private
DishNode
curSelectDishNode
;
public
static
DishesFragment
newInstance
()
{
...
...
@@ -85,26 +90,55 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp
}
private
void
initDishDetail
(
DishDetailResultBean
dishesResultBean
){
List
<
DishDetailBean
>
foods
=
dishesResultBean
.
getData
();
View
footer
;
if
(
CollectionUtils
.
isNullOrEmpty
(
foods
))
{
dishDetailAdapter
=
new
DishDetailAdapter
(
requireContext
(),
new
ArrayList
<>());
footer
=
getFooterView
(
false
);
}
else
{
dishDetailAdapter
=
new
DishDetailAdapter
(
requireContext
(),
foods
);
footer
=
getFooterView
(
true
);
}
LinearLayout
parent
=
dishDetailAdapter
.
getFooterLayout
();
if
(
parent
==
null
)
{
dishDetailAdapter
.
removeAllFooterView
();
dishDetailAdapter
.
addFooterView
(
footer
);
}
else
{
dishDetailAdapter
=
new
DishDetailAdapter
(
requireContext
(),
new
ArrayList
<>());
parent
.
removeAllViews
();
dishDetailAdapter
.
addFooterView
(
footer
);
}
dishDetailAdapter
.
addFooterView
(
getFooter
());
rvDishes
.
setLayoutManager
(
new
LinearLayoutManager
(
requireContext
(),
LinearLayoutManager
.
VERTICAL
,
false
));
rvDishes
.
setAdapter
(
dishDetailAdapter
);
}
private
View
getFooter
()
{
View
view
=
getLayoutInflater
().
inflate
(
R
.
layout
.
item_dishes_foot
,
rvDishes
,
false
);
view
.
findViewById
(
R
.
id
.
tv_dish_add
).
setOnClickListener
(
v
->
{
private
View
getFooterView
(
boolean
showDone
)
{
if
(
footView
==
null
)
{
footView
=
getLayoutInflater
().
inflate
(
R
.
layout
.
item_dishes_foot
,
rvDishes
,
false
);
footView
.
findViewById
(
R
.
id
.
tv_dish_add
).
setOnClickListener
(
v
->
{
startForResult
(
OtherFunctionFragment
.
newInstance
(),
DISHES_ADD
);
});
view
.
findViewById
(
R
.
id
.
tv_dish_done
).
setOnClickListener
(
v
->
{
footView
.
findViewById
(
R
.
id
.
tv_dish_done
).
setOnClickListener
(
v
->
{
if
(
curSelectDishNode
!=
null
)
{
List
<
DishDetailBean
>
detailBeans
=
dishDetailAdapter
.
getData
();
if
(
CollectionUtils
.
isNotNullOrEmpty
(
detailBeans
))
{
mPresenter
.
bindDishFoods
(
detailBeans
);
}
}
LogUtil
.
e
(
"zjs"
,
" 完成 tv_dish_done"
);
});
return
view
;
}
if
(
showDone
)
{
footView
.
findViewById
(
R
.
id
.
tv_dish_done
).
setVisibility
(
View
.
VISIBLE
);
}
else
{
footView
.
findViewById
(
R
.
id
.
tv_dish_done
).
setVisibility
(
View
.
GONE
);
}
return
footView
;
}
private
void
initDishGroup
(
List
<
DishesGroupNode
>
dishesGroupNodes
){
dishesTreeAdapter
=
new
DishesTreeAdapter
(
dishNode
->
mPresenter
.
getDishesDetailData
(
dishNode
));
dishesTreeAdapter
.
setOnItemChildClickListener
((
adapter
,
view
,
position
)
->
{
...
...
@@ -147,6 +181,7 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp
@Override
public
void
loadDishesInfo
(
DishNode
dishNode
,
DishDetailResultBean
dishesDetail
)
{
curSelectDishNode
=
dishNode
;
initDishDetail
(
dishesDetail
);
}
...
...
@@ -177,7 +212,7 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp
LogUtil
.
e
(
"zjs"
,
" onFragmentResult ="
+
requestCode
+
" resultCode="
+
resultCode
);
if
(
requestCode
==
DISHES_ADD
)
{
if
(
data
!=
null
)
{
if
(
dishDetailAdapter
!=
null
)
{
if
(
dishDetailAdapter
!=
null
&&
curSelectDishNode
!=
null
)
{
List
<
DishDetailBean
>
foodsOld
=
dishDetailAdapter
.
getData
();
ArrayList
<
PurchaseFoodBean
>
purchaseFood
=
(
ArrayList
<
PurchaseFoodBean
>)
data
.
getSerializable
(
"zjs"
);
if
(
purchaseFood
!=
null
)
{
...
...
@@ -200,22 +235,27 @@ public class DishesFragment extends BaseSupplyChainFragment<DishesPresenter> imp
}
}
if
(
isNew
)
{
DishDetailBean
addNewBean
=
new
DishDetailBean
(
newBean
);
DishDetailBean
addNewBean
=
new
DishDetailBean
(
newBean
,
curSelectDishNode
);
foodsNew
.
add
(
addNewBean
);
}
}
}
else
{
//全新
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
PurchaseFoodBean
newBean
=
purchaseFood
.
get
(
i
);
LogUtil
.
e
(
"zjs"
,
" 全新 newBean="
+
newBean
.
toString
());
DishDetailBean
addNewBean
=
new
DishDetailBean
(
newBean
);
DishDetailBean
addNewBean
=
new
DishDetailBean
(
newBean
,
curSelectDishNode
);
foodsNew
.
add
(
addNewBean
);
}
}
// TODO: 2021/7/26 完成按钮显示 菜品数据绑定
dishDetailAdapter
.
addData
(
foodsNew
);
DishDetailResultBean
detailResultBean
=
curSelectDishNode
.
getDetailBean
();
if
(
detailResultBean
==
null
)
{
detailResultBean
=
new
DishDetailResultBean
();
}
detailResultBean
.
setData
(
dishDetailAdapter
.
getData
());
curSelectDishNode
.
setDetailBean
(
detailResultBean
);
getFooterView
(
true
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment