制作模式、采样模式数据保存支持多食堂模式,制作模式查询菜品列表和搜索菜品增加餐次字段,设置页面增加隐藏默认数据导入功能
This commit is contained in:
Generated
+2
-2
@@ -4,10 +4,10 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2025-08-15T07:06:48.695133800Z">
|
<DropdownSelection timestamp="2025-08-18T06:18:22.594579400Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="Default" identifier="serial=192.168.1.185:5555;connection=66c1b774" />
|
<DeviceId pluginId="Default" identifier="serial=192.168.1.185:5555;connection=2158168e" />
|
||||||
</handle>
|
</handle>
|
||||||
</Target>
|
</Target>
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
|
|||||||
@@ -0,0 +1,208 @@
|
|||||||
|
{
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"id" : 1,
|
||||||
|
"goodsId" : "17899",
|
||||||
|
"goodsName" : "精盐",
|
||||||
|
"foodId" : "",
|
||||||
|
"goodsOrRelationCode" : "WP0278",
|
||||||
|
"relateionType" : 1,
|
||||||
|
"materialType" : 3,
|
||||||
|
"allEdible" : 1,
|
||||||
|
"useWeight" : 0.0,
|
||||||
|
"popularName" : "食盐、精制盐",
|
||||||
|
"canteenId" : "1678234139391512577",
|
||||||
|
"relateionType_dictText" : "食材原材料",
|
||||||
|
"sort" : 0,
|
||||||
|
"isDel" : 0,
|
||||||
|
"createTime" : "2025-08-18 10:16:17"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 2,
|
||||||
|
"goodsId" : "17901",
|
||||||
|
"goodsName" : "鸡精",
|
||||||
|
"foodId" : "",
|
||||||
|
"goodsOrRelationCode" : "WP0280",
|
||||||
|
"relateionType" : 1,
|
||||||
|
"materialType" : 3,
|
||||||
|
"allEdible" : 1,
|
||||||
|
"useWeight" : 0.0,
|
||||||
|
"popularName" : "鸡精、家乐鸡精",
|
||||||
|
"canteenId" : "1678234139391512577",
|
||||||
|
"relateionType_dictText" : "食材原材料",
|
||||||
|
"sort" : 1,
|
||||||
|
"isDel" : 0,
|
||||||
|
"createTime" : "2025-08-18 10:17:02"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 3,
|
||||||
|
"goodsId" : "17752",
|
||||||
|
"goodsName" : "味精",
|
||||||
|
"foodId" : "",
|
||||||
|
"goodsOrRelationCode" : "WP0131",
|
||||||
|
"relateionType" : 1,
|
||||||
|
"materialType" : 3,
|
||||||
|
"allEdible" : 1,
|
||||||
|
"useWeight" : 0.0,
|
||||||
|
"popularName" : "双桥味精,莲花味精、味精",
|
||||||
|
"canteenId" : "1678234139391512577",
|
||||||
|
"relateionType_dictText" : "食材原材料",
|
||||||
|
"sort" : 2,
|
||||||
|
"isDel" : 0,
|
||||||
|
"createTime" : "2025-08-18 10:17:16"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 4,
|
||||||
|
"goodsId" : "17800",
|
||||||
|
"goodsName" : "老抽",
|
||||||
|
"foodId" : "",
|
||||||
|
"goodsOrRelationCode" : "WP0179",
|
||||||
|
"relateionType" : 1,
|
||||||
|
"materialType" : 3,
|
||||||
|
"allEdible" : 1,
|
||||||
|
"useWeight" : 0.0,
|
||||||
|
"popularName" : "老抽",
|
||||||
|
"canteenId" : "1678234139391512577",
|
||||||
|
"relateionType_dictText" : "食材原材料",
|
||||||
|
"sort" : 3,
|
||||||
|
"isDel" : 0,
|
||||||
|
"createTime" : "2025-08-18 10:17:26"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 5,
|
||||||
|
"goodsId" : "17749",
|
||||||
|
"goodsName" : "白醋",
|
||||||
|
"foodId" : "",
|
||||||
|
"goodsOrRelationCode" : "WP0128",
|
||||||
|
"relateionType" : 1,
|
||||||
|
"materialType" : 3,
|
||||||
|
"allEdible" : 1,
|
||||||
|
"useWeight" : 0.0,
|
||||||
|
"popularName" : "白醋,唯加白醋",
|
||||||
|
"canteenId" : "1678234139391512577",
|
||||||
|
"relateionType_dictText" : "食材原材料",
|
||||||
|
"sort" : 4,
|
||||||
|
"isDel" : 0,
|
||||||
|
"createTime" : "2025-08-18 10:17:38"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 6,
|
||||||
|
"goodsId" : "17895",
|
||||||
|
"goodsName" : "胡椒粉",
|
||||||
|
"foodId" : "",
|
||||||
|
"goodsOrRelationCode" : "WP0274",
|
||||||
|
"relateionType" : 1,
|
||||||
|
"materialType" : 3,
|
||||||
|
"allEdible" : 1,
|
||||||
|
"useWeight" : 0.0,
|
||||||
|
"popularName" : "胡椒粉",
|
||||||
|
"canteenId" : "1678234139391512577",
|
||||||
|
"relateionType_dictText" : "食材原材料",
|
||||||
|
"sort" : 5,
|
||||||
|
"isDel" : 0,
|
||||||
|
"createTime" : "2025-08-18 10:17:47"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 7,
|
||||||
|
"goodsId" : "329",
|
||||||
|
"goodsName" : "酱油",
|
||||||
|
"foodId" : "",
|
||||||
|
"goodsOrRelationCode" : "WP0329",
|
||||||
|
"relateionType" : 1,
|
||||||
|
"materialType" : 3,
|
||||||
|
"allEdible" : 1,
|
||||||
|
"useWeight" : 0.0,
|
||||||
|
"popularName" : "酱油",
|
||||||
|
"canteenId" : "1678234139391512577",
|
||||||
|
"relateionType_dictText" : "食材原材料",
|
||||||
|
"sort" : 6,
|
||||||
|
"isDel" : 0,
|
||||||
|
"createTime" : "2025-08-18 10:17:55"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 8,
|
||||||
|
"goodsId" : "17733",
|
||||||
|
"goodsName" : "料酒",
|
||||||
|
"foodId" : "",
|
||||||
|
"goodsOrRelationCode" : "WP0112",
|
||||||
|
"relateionType" : 1,
|
||||||
|
"materialType" : 3,
|
||||||
|
"allEdible" : 1,
|
||||||
|
"useWeight" : 0.0,
|
||||||
|
"popularName" : "料酒",
|
||||||
|
"canteenId" : "1678234139391512577",
|
||||||
|
"relateionType_dictText" : "食材原材料",
|
||||||
|
"sort" : 7,
|
||||||
|
"isDel" : 0,
|
||||||
|
"createTime" : "2025-08-18 10:18:14"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 9,
|
||||||
|
"goodsId" : "17889",
|
||||||
|
"goodsName" : "五香粉",
|
||||||
|
"foodId" : "",
|
||||||
|
"goodsOrRelationCode" : "WP0268",
|
||||||
|
"relateionType" : 1,
|
||||||
|
"materialType" : 3,
|
||||||
|
"allEdible" : 1,
|
||||||
|
"useWeight" : 0.0,
|
||||||
|
"popularName" : "五香粉",
|
||||||
|
"canteenId" : "1678234139391512577",
|
||||||
|
"relateionType_dictText" : "食材原材料",
|
||||||
|
"sort" : 8,
|
||||||
|
"isDel" : 0,
|
||||||
|
"createTime" : "2025-08-18 10:18:23"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 10,
|
||||||
|
"goodsId" : "17815",
|
||||||
|
"goodsName" : "豆瓣酱",
|
||||||
|
"foodId" : "",
|
||||||
|
"goodsOrRelationCode" : "WP0194",
|
||||||
|
"relateionType" : 1,
|
||||||
|
"materialType" : 3,
|
||||||
|
"allEdible" : 1,
|
||||||
|
"useWeight" : 0.0,
|
||||||
|
"popularName" : "豆瓣酱、郫县豆瓣酱",
|
||||||
|
"canteenId" : "1678234139391512577",
|
||||||
|
"relateionType_dictText" : "食材原材料",
|
||||||
|
"sort" : 9,
|
||||||
|
"isDel" : 0,
|
||||||
|
"createTime" : "2025-08-18 10:18:31"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 11,
|
||||||
|
"goodsId" : "17803",
|
||||||
|
"goodsName" : "生抽",
|
||||||
|
"foodId" : "",
|
||||||
|
"goodsOrRelationCode" : "WP0182",
|
||||||
|
"relateionType" : 1,
|
||||||
|
"materialType" : 3,
|
||||||
|
"allEdible" : 1,
|
||||||
|
"useWeight" : 0.0,
|
||||||
|
"popularName" : "生抽",
|
||||||
|
"canteenId" : "1678234139391512577",
|
||||||
|
"relateionType_dictText" : "食材原材料",
|
||||||
|
"sort" : 12,
|
||||||
|
"isDel" : 0,
|
||||||
|
"createTime" : "2025-08-18 10:19:08"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : 12,
|
||||||
|
"goodsId" : "18032",
|
||||||
|
"goodsName" : "菜籽油[青油]",
|
||||||
|
"foodId" : "",
|
||||||
|
"goodsOrRelationCode" : "WP0411",
|
||||||
|
"relateionType" : 1,
|
||||||
|
"materialType" : 3,
|
||||||
|
"allEdible" : 1,
|
||||||
|
"useWeight" : 0.0,
|
||||||
|
"popularName" : "菜籽油,爱菊菜籽油",
|
||||||
|
"canteenId" : "1678234139391512577",
|
||||||
|
"relateionType_dictText" : "食材原材料",
|
||||||
|
"sort" : 14,
|
||||||
|
"isDel" : 0,
|
||||||
|
"createTime" : "2025-08-18 10:19:19"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -20,7 +20,8 @@ class BaseApp : Application() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
const val canteenId = "1678234139391512577"
|
// const val canteenId = "1678234139391512577"
|
||||||
|
const val canteenId = "0"
|
||||||
@Volatile
|
@Volatile
|
||||||
private var sharedPref: SharedPreferences? = null
|
private var sharedPref: SharedPreferences? = null
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.shuwei.dish.match.db
|
package com.shuwei.dish.match.db
|
||||||
|
|
||||||
|
import com.shuwei.dish.match.base.BaseApp
|
||||||
import com.shuwei.dish.match.db.dao.AppDao
|
import com.shuwei.dish.match.db.dao.AppDao
|
||||||
import com.shuwei.dish.match.entity.CookFoodEntity
|
import com.shuwei.dish.match.entity.CookFoodEntity
|
||||||
import com.shuwei.dish.match.entity.CookFoodGoodsEntity
|
import com.shuwei.dish.match.entity.CookFoodGoodsEntity
|
||||||
@@ -19,41 +20,41 @@ class AppRepository(val appDao: AppDao) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getCookFoodById(foodId: String, cookMode: Int) = withContext(Dispatchers.IO) {
|
suspend fun getCookFoodById(foodId: String, cookMode: Int) = withContext(Dispatchers.IO) {
|
||||||
appDao.getCookFoodById(foodId, cookMode)
|
appDao.getCookFoodById(BaseApp.canteenId, foodId, cookMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getCookFoodList(cookMode: Int) = withContext(Dispatchers.IO) {
|
suspend fun getCookFoodList(cookMode: Int, dinnerType: String) = withContext(Dispatchers.IO) {
|
||||||
appDao.getCookFoodList(cookMode)
|
appDao.getCookFoodList(BaseApp.canteenId, cookMode, dinnerType)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun countCookFood(cookMode: Int) = withContext(Dispatchers.IO) {
|
suspend fun countCookFood(cookMode: Int) = withContext(Dispatchers.IO) {
|
||||||
appDao.countCookFood(cookMode)
|
appDao.countCookFood(BaseApp.canteenId, cookMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun deleteCookFood(foodId: String, cookMode: Int) = withContext(Dispatchers.IO) {
|
suspend fun deleteCookFood(foodId: String, cookMode: Int) = withContext(Dispatchers.IO) {
|
||||||
appDao.deleteCookFood(foodId, cookMode)
|
appDao.deleteCookFood(BaseApp.canteenId, foodId, cookMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun deleteCookFoodGoodsList(foodId: String) = withContext(Dispatchers.IO) {
|
suspend fun deleteCookFoodGoodsList(pid:Long, foodId: String) = withContext(Dispatchers.IO) {
|
||||||
appDao.deleteCookFoodGoodsList(foodId)
|
appDao.deleteCookFoodGoodsList(pid, foodId)
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
suspend fun insertGoods(item: CookFoodGoodsEntity) = withContext(Dispatchers.IO) {
|
// suspend fun insertGoods(item: CookFoodGoodsEntity) = withContext(Dispatchers.IO) {
|
||||||
appDao.insertGoods(item)
|
// appDao.insertGoods(item)
|
||||||
}
|
// }
|
||||||
|
|
||||||
suspend fun insertGoodsList(items: MutableList<CookFoodGoodsEntity>) =
|
suspend fun insertGoodsList(items: MutableList<CookFoodGoodsEntity>) =
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
appDao.insertGoodsList(items)
|
appDao.insertGoodsList(items)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun updateGoods(item: CookFoodGoodsEntity) = withContext(Dispatchers.IO) {
|
// suspend fun updateGoods(item: CookFoodGoodsEntity) = withContext(Dispatchers.IO) {
|
||||||
appDao.updateGoods(item)
|
// appDao.updateGoods(item)
|
||||||
}
|
// }
|
||||||
|
|
||||||
suspend fun getCookFoodGoodsList(foodId: String) = withContext(Dispatchers.IO) {
|
suspend fun getCookFoodGoodsList(pid:Long, foodId: String) = withContext(Dispatchers.IO) {
|
||||||
appDao.getCookFoodGoodsList(foodId)
|
appDao.getCookFoodGoodsList(pid, foodId)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getCookFoodGoodsListByType(
|
suspend fun getCookFoodGoodsListByType(
|
||||||
@@ -84,8 +85,8 @@ class AppRepository(val appDao: AppDao) {
|
|||||||
appDao.search(query)
|
appDao.search(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun deleteBatch() = withContext(Dispatchers.IO) {
|
suspend fun clearAllSeasoning() = withContext(Dispatchers.IO) {
|
||||||
appDao.deleteBatch()
|
appDao.clearAllSeasoning()
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun deleteEmptySeasoning() = withContext(Dispatchers.IO) {
|
suspend fun deleteEmptySeasoning() = withContext(Dispatchers.IO) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.shuwei.dish.match.db.dao
|
package com.shuwei.dish.match.db.dao
|
||||||
|
|
||||||
import androidx.room.Dao
|
import androidx.room.Dao
|
||||||
import androidx.room.Delete
|
|
||||||
import androidx.room.Insert
|
import androidx.room.Insert
|
||||||
import androidx.room.OnConflictStrategy
|
import androidx.room.OnConflictStrategy
|
||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
@@ -20,17 +19,17 @@ interface AppDao {
|
|||||||
@Update
|
@Update
|
||||||
suspend fun updateCookFood(item: CookFoodEntity)
|
suspend fun updateCookFood(item: CookFoodEntity)
|
||||||
|
|
||||||
@Query("SELECT * FROM dm_cook_food WHERE isDel = 0 AND foodId = :foodId AND cookMode = :cookMode")
|
@Query("SELECT * FROM dm_cook_food WHERE isDel = 0 AND canteenId = :canteenId AND foodId = :foodId AND cookMode = :cookMode")
|
||||||
suspend fun getCookFoodById(foodId: String, cookMode: Int): CookFoodEntity?
|
suspend fun getCookFoodById(canteenId:String, foodId: String, cookMode: Int): CookFoodEntity?
|
||||||
|
|
||||||
@Query("SELECT * FROM dm_cook_food WHERE isDel = 0 AND cookMode = :cookMode ORDER BY createTime DESC")
|
@Query("SELECT * FROM dm_cook_food WHERE isDel = 0 AND canteenId = :canteenId AND cookMode = :cookMode AND dinnerType = :dinnerType ORDER BY createTime DESC")
|
||||||
suspend fun getCookFoodList(cookMode: Int): MutableList<CookFoodEntity>?
|
suspend fun getCookFoodList(canteenId:String, cookMode: Int, dinnerType:String): MutableList<CookFoodEntity>?
|
||||||
|
|
||||||
@Query("SELECT count(1) FROM dm_cook_food WHERE isDel = 0 AND cookMode = :cookMode")
|
@Query("SELECT count(1) FROM dm_cook_food WHERE isDel = 0 AND canteenId = :canteenId AND cookMode = :cookMode")
|
||||||
suspend fun countCookFood(cookMode: Int): Int
|
suspend fun countCookFood(canteenId:String, cookMode: Int): Int
|
||||||
|
|
||||||
@Query("DELETE FROM dm_cook_food WHERE foodId = :foodId AND cookMode = :cookMode")
|
@Query("DELETE FROM dm_cook_food WHERE canteenId = :canteenId AND foodId = :foodId AND cookMode = :cookMode")
|
||||||
suspend fun deleteCookFood(foodId: String, cookMode: Int)
|
suspend fun deleteCookFood(canteenId:String, foodId: String, cookMode: Int)
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -43,8 +42,8 @@ interface AppDao {
|
|||||||
@Update
|
@Update
|
||||||
suspend fun updateGoods(item: CookFoodGoodsEntity)
|
suspend fun updateGoods(item: CookFoodGoodsEntity)
|
||||||
|
|
||||||
@Query("SELECT * FROM dm_cook_food_goods WHERE isDel = 0 AND foodId = :foodId")
|
@Query("SELECT * FROM dm_cook_food_goods WHERE isDel = 0 AND pid = :pid AND foodId = :foodId")
|
||||||
suspend fun getCookFoodGoodsList(foodId: String): MutableList<CookFoodGoodsEntity>
|
suspend fun getCookFoodGoodsList(pid:Long, foodId: String): MutableList<CookFoodGoodsEntity>
|
||||||
|
|
||||||
@Query("SELECT * FROM dm_cook_food_goods WHERE isDel = 0 AND foodId = :foodId AND materialType = :materialType")
|
@Query("SELECT * FROM dm_cook_food_goods WHERE isDel = 0 AND foodId = :foodId AND materialType = :materialType")
|
||||||
suspend fun getCookFoodGoodsListByType(
|
suspend fun getCookFoodGoodsListByType(
|
||||||
@@ -52,8 +51,8 @@ interface AppDao {
|
|||||||
materialType: Int
|
materialType: Int
|
||||||
): MutableList<CookFoodGoodsEntity>
|
): MutableList<CookFoodGoodsEntity>
|
||||||
|
|
||||||
@Query("DELETE FROM dm_cook_food_goods WHERE foodId = :foodId")
|
@Query("DELETE FROM dm_cook_food_goods WHERE pid = :pid AND foodId = :foodId")
|
||||||
suspend fun deleteCookFoodGoodsList(foodId: String)
|
suspend fun deleteCookFoodGoodsList(pid:Long, foodId: String)
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -76,7 +75,7 @@ interface AppDao {
|
|||||||
suspend fun deleteEmptySeasoning(): Int
|
suspend fun deleteEmptySeasoning(): Int
|
||||||
|
|
||||||
@Query("DELETE FROM dm_seasoning WHERE isDel = 0")
|
@Query("DELETE FROM dm_seasoning WHERE isDel = 0")
|
||||||
suspend fun deleteBatch(): Int
|
suspend fun clearAllSeasoning(): Int
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
suspend fun insertSeasoningList(items: MutableList<SeasoningEntity>): Array<Long>
|
suspend fun insertSeasoningList(items: MutableList<SeasoningEntity>): Array<Long>
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ import java.time.LocalDateTime
|
|||||||
|
|
||||||
@Entity(tableName = "dm_cook_food")
|
@Entity(tableName = "dm_cook_food")
|
||||||
data class CookFoodEntity(
|
data class CookFoodEntity(
|
||||||
@PrimaryKey
|
@PrimaryKey(autoGenerate = true)
|
||||||
|
var id: Long = 0,
|
||||||
var foodId: String,
|
var foodId: String,
|
||||||
var foodName: String? = null,
|
var foodName: String? = null,
|
||||||
var canteenId: String? = null,
|
var canteenId: String? = null,
|
||||||
@@ -18,6 +19,7 @@ data class CookFoodEntity(
|
|||||||
var cookMode:Int = 0,
|
var cookMode:Int = 0,
|
||||||
var isDel: Int = 0,
|
var isDel: Int = 0,
|
||||||
var createTime: String = DateTimeUtil.formatDateTime(LocalDateTime.now()),
|
var createTime: String = DateTimeUtil.formatDateTime(LocalDateTime.now()),
|
||||||
|
var dinnerType: String? = "0",
|
||||||
) : BaseEntity {
|
) : BaseEntity {
|
||||||
@Ignore
|
@Ignore
|
||||||
var stFoodInfoConstituteList: MutableList<CookFoodGoodsEntity>? = null
|
var stFoodInfoConstituteList: MutableList<CookFoodGoodsEntity>? = null
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import java.time.LocalDateTime
|
|||||||
class CookFoodGoodsEntity(
|
class CookFoodGoodsEntity(
|
||||||
@PrimaryKey(autoGenerate = true)
|
@PrimaryKey(autoGenerate = true)
|
||||||
var id: Long = 0,
|
var id: Long = 0,
|
||||||
|
//多个食堂存在同一个foodId,使用pid(dm_cook_food表主键)对应父记录数据
|
||||||
|
var pid: Long = 0,
|
||||||
/**
|
/**
|
||||||
* 物品id
|
* 物品id
|
||||||
*/
|
*/
|
||||||
@@ -64,10 +66,13 @@ class CookFoodGoodsEntity(
|
|||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
var isSetFinished: Boolean = false
|
var isSetFinished: Boolean = false
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
var isItemClicked: Boolean = false
|
var isItemClicked: Boolean = false
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
var isSamplingPage: Boolean = false
|
var isSamplingPage: Boolean = false
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
var isNewDishType: Boolean = false
|
var isNewDishType: Boolean = false
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ data class SeasoningRecordBean(
|
|||||||
var page: Int
|
var page: Int
|
||||||
)
|
)
|
||||||
|
|
||||||
|
data class ResetReasoningRecord(
|
||||||
|
val list: MutableList<SeasoningEntity>
|
||||||
|
)
|
||||||
|
|
||||||
//data class DishDetailEntity(
|
//data class DishDetailEntity(
|
||||||
// var foodId: String? = null,
|
// var foodId: String? = null,
|
||||||
// var foodWeight: Double? = null,
|
// var foodWeight: Double? = null,
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ data class FoodRecord(
|
|||||||
var isCooking: Boolean = false,
|
var isCooking: Boolean = false,
|
||||||
//0-制作模式,1-采样模式,2-品控模式
|
//0-制作模式,1-采样模式,2-品控模式
|
||||||
var cookMode: Int = 0,
|
var cookMode: Int = 0,
|
||||||
|
//1-早餐,2-午餐,3-晚餐
|
||||||
|
var dinnerType: String = "0",
|
||||||
|
|
||||||
var sort: Int = 0
|
var sort: Int = 0
|
||||||
) : Serializable
|
) : Serializable
|
||||||
|
|||||||
@@ -7,27 +7,30 @@ import android.text.style.AbsoluteSizeSpan
|
|||||||
import android.text.style.ForegroundColorSpan
|
import android.text.style.ForegroundColorSpan
|
||||||
import android.text.style.LineHeightSpan
|
import android.text.style.LineHeightSpan
|
||||||
import android.text.style.StyleSpan
|
import android.text.style.StyleSpan
|
||||||
import android.util.Log
|
|
||||||
import androidx.core.graphics.toColorInt
|
import androidx.core.graphics.toColorInt
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import com.shuwei.dish.match.R
|
|
||||||
import com.shuwei.dish.match.adapter.SeasoningCellTool
|
import com.shuwei.dish.match.adapter.SeasoningCellTool
|
||||||
import com.shuwei.dish.match.adapter.TextCellAdapter
|
|
||||||
import com.shuwei.dish.match.base.BaseActivity
|
import com.shuwei.dish.match.base.BaseActivity
|
||||||
import com.shuwei.dish.match.base.BaseApp
|
import com.shuwei.dish.match.base.BaseApp
|
||||||
import com.shuwei.dish.match.databinding.ActivityDeviceSettingBinding
|
import com.shuwei.dish.match.databinding.ActivityDeviceSettingBinding
|
||||||
|
import com.shuwei.dish.match.databinding.LayoutFoodRemindBinding
|
||||||
import com.shuwei.dish.match.db.AppRepository
|
import com.shuwei.dish.match.db.AppRepository
|
||||||
|
import com.shuwei.dish.match.dialog.CommonDialog
|
||||||
import com.shuwei.dish.match.entity.SeasoningEntity
|
import com.shuwei.dish.match.entity.SeasoningEntity
|
||||||
|
import com.shuwei.dish.match.entity.ResetReasoningRecord
|
||||||
|
import com.shuwei.dish.match.utils.DataUtil
|
||||||
|
import com.shuwei.dish.match.utils.JsonAssetsLoader
|
||||||
|
import com.shuwei.dish.match.utils.MultiClickDetector
|
||||||
|
import com.shuwei.dish.match.utils.WeightUtil
|
||||||
import com.shuwei.dish.match.utils.ext.appendText
|
import com.shuwei.dish.match.utils.ext.appendText
|
||||||
import com.shuwei.dish.match.utils.ext.buildSpannableString
|
import com.shuwei.dish.match.utils.ext.buildSpannableString
|
||||||
import com.shuwei.dish.match.utils.ext.dp
|
import com.shuwei.dish.match.utils.ext.dp
|
||||||
import com.shuwei.dish.match.utils.ext.startActivity
|
import com.shuwei.dish.match.utils.ext.startActivity
|
||||||
import com.shuwei.dish.match.utils.ext.toJsonString
|
|
||||||
import com.shuwei.dish.match.utils.ext.toast
|
import com.shuwei.dish.match.utils.ext.toast
|
||||||
import com.shuwei.dish.match.utils.ext.visible
|
import com.shuwei.dish.match.utils.ext.visible
|
||||||
import com.shuwei.dish.match.viewmodel.AppViewModel
|
import com.shuwei.dish.match.viewmodel.AppViewModel
|
||||||
import com.shuwei.dish.match.viewmodel.factory.AppFactory
|
import com.shuwei.dish.match.viewmodel.factory.AppFactory
|
||||||
|
import com.shuwei.dish.match.R
|
||||||
|
|
||||||
class DeviceSettingActivity : BaseActivity() {
|
class DeviceSettingActivity : BaseActivity() {
|
||||||
|
|
||||||
@@ -53,8 +56,6 @@ class DeviceSettingActivity : BaseActivity() {
|
|||||||
|
|
||||||
private lateinit var appViewModel: AppViewModel
|
private lateinit var appViewModel: AppViewModel
|
||||||
|
|
||||||
// public lateinit var list: MutableList<SeasoningEntity>
|
|
||||||
|
|
||||||
private var cookMode: Int = 0
|
private var cookMode: Int = 0
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@@ -68,10 +69,20 @@ class DeviceSettingActivity : BaseActivity() {
|
|||||||
it.visible()
|
it.visible()
|
||||||
}, titleAction = {
|
}, titleAction = {
|
||||||
it.text = "设备配置"
|
it.text = "设备配置"
|
||||||
|
}, rightIconActon = {
|
||||||
|
it.visible()
|
||||||
|
it.alpha = 0.0F
|
||||||
|
it.setImageResource(R.drawable.ic_setting)
|
||||||
|
it.setOnClickListener {
|
||||||
|
// appViewModel.clearAllSeasoning{
|
||||||
|
// loadSeasoning()
|
||||||
|
// }
|
||||||
|
detector.setOnDelayedMultiClickListener(it) {
|
||||||
|
defaultDataSettingDialog()
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
addListener()
|
|
||||||
|
|
||||||
loadQualitySpan(isEnable = false)
|
loadQualitySpan(isEnable = false)
|
||||||
when (cookMode) {
|
when (cookMode) {
|
||||||
1 -> {
|
1 -> {
|
||||||
@@ -80,12 +91,14 @@ class DeviceSettingActivity : BaseActivity() {
|
|||||||
loadCookSpan(isClicked = true)
|
loadCookSpan(isClicked = true)
|
||||||
loadSamplingSpan()
|
loadSamplingSpan()
|
||||||
}
|
}
|
||||||
|
|
||||||
2 -> {
|
2 -> {
|
||||||
binding.rbModeCook.isChecked = false
|
binding.rbModeCook.isChecked = false
|
||||||
binding.rbModeSampling.isChecked = true
|
binding.rbModeSampling.isChecked = true
|
||||||
loadCookSpan()
|
loadCookSpan()
|
||||||
loadSamplingSpan(isClicked = true)
|
loadSamplingSpan(isClicked = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> 0
|
else -> 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,6 +120,40 @@ class DeviceSettingActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val detector = MultiClickDetector(targetCount = 10, intervalMs = 800)
|
||||||
|
|
||||||
|
private fun defaultDataSettingDialog() {
|
||||||
|
val remindBinding = LayoutFoodRemindBinding.inflate(layoutInflater)
|
||||||
|
remindBinding.tvDialogTitle.text = "温馨提示"
|
||||||
|
remindBinding.tvDialogContent.text = "您好,使用默认配置作为您的调料数据,则已有配置将被清除,确认吗?"
|
||||||
|
CommonDialog(this).apply {
|
||||||
|
messageView = remindBinding.root
|
||||||
|
leftText = "取消"
|
||||||
|
rightText = "确认"
|
||||||
|
onLeftClick = { dismiss() }
|
||||||
|
onRightClick = {
|
||||||
|
dismiss()
|
||||||
|
resetList()
|
||||||
|
}
|
||||||
|
onDismiss = { hideStatusBar() }
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun resetList() {
|
||||||
|
runCatching {
|
||||||
|
val record = JsonAssetsLoader.parseJsonFromAssets<ResetReasoningRecord>(this,"default_seasoning_list.json")
|
||||||
|
val addressArray = DataUtil.getWeighAddressArray()
|
||||||
|
val weightArray = WeightUtil.weightArray
|
||||||
|
appViewModel.clearAllSeasoning {
|
||||||
|
record?.list?.forEach { entity ->
|
||||||
|
entity.useWeight = weightArray[addressArray[entity.sort]].toDouble()
|
||||||
|
appViewModel.saveSeasoning(entity){}
|
||||||
|
}
|
||||||
|
loadSeasoning()
|
||||||
|
}
|
||||||
|
}.onFailure { it.printStackTrace() }
|
||||||
|
}
|
||||||
|
|
||||||
private fun initViewModel() {
|
private fun initViewModel() {
|
||||||
val db = BaseApp.instance!!.database
|
val db = BaseApp.instance!!.database
|
||||||
val factory =
|
val factory =
|
||||||
@@ -117,6 +164,10 @@ class DeviceSettingActivity : BaseActivity() {
|
|||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
loadSeasoning()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun loadSeasoning() {
|
||||||
appViewModel.loadSeasoning { it ->
|
appViewModel.loadSeasoning { it ->
|
||||||
SeasoningCellTool.loadData(
|
SeasoningCellTool.loadData(
|
||||||
activity = this,
|
activity = this,
|
||||||
@@ -125,79 +176,9 @@ class DeviceSettingActivity : BaseActivity() {
|
|||||||
tvCell = binding.tvRightBottomCell,
|
tvCell = binding.tvRightBottomCell,
|
||||||
pageType = 1
|
pageType = 1
|
||||||
)
|
)
|
||||||
// (binding.rvSeasoning.adapter as TextCellAdapter).let { adapter ->
|
|
||||||
// list = adapter.list
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private var isCookMode: Boolean = true
|
|
||||||
|
|
||||||
private fun addListener() {
|
|
||||||
// binding.modeRadioGroup.setOnCheckedChangeListener { _, checkedId ->
|
|
||||||
// when (checkedId) {
|
|
||||||
// R.id.rbModeCook -> {
|
|
||||||
// isCookMode = true
|
|
||||||
// loadCookSpan(isClicked = true)
|
|
||||||
// loadSamplingSpan()
|
|
||||||
// loadQualitySpan(isEnable = false)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// R.id.rbModeSampling -> {
|
|
||||||
// isCookMode = false
|
|
||||||
// loadCookSpan()
|
|
||||||
// loadSamplingSpan(isClicked = true)
|
|
||||||
// loadQualitySpan(isEnable = false)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// R.id.rbModeQuality -> {
|
|
||||||
// loadCookSpan()
|
|
||||||
// loadSamplingSpan()
|
|
||||||
// loadQualitySpan(isEnable = false)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// binding.btnCancel.setOnClickListener { finish() }
|
|
||||||
// binding.btnConfirm.setOnClickListener { confirmSetting() }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun confirmSetting() {
|
|
||||||
// runCatching {
|
|
||||||
// showLoading()
|
|
||||||
//// list.forEachIndexed { index, entity ->
|
|
||||||
//// entity.sort = index
|
|
||||||
//// }
|
|
||||||
//// val list2 = mutableListOf<SeasoningEntity>()
|
|
||||||
//// list2.addAll(list)
|
|
||||||
//// val array = arrayOf(10, 11, 13)
|
|
||||||
//// list.forEachIndexed { index, entity ->
|
|
||||||
//// if (entity.sort == 14 && array.contains(index)) {
|
|
||||||
//// list2.remove(entity)
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
// Log.d(TAG, "addListener->Click: ${list.toJsonString()}")
|
|
||||||
//
|
|
||||||
// appViewModel.addSeasoning(list) {
|
|
||||||
// dismissLoading()
|
|
||||||
// if (isCookMode) {
|
|
||||||
// startActivity<SelectDishActivity> { }
|
|
||||||
// } else {
|
|
||||||
// startActivity<SamplingListActivity> { }
|
|
||||||
// }
|
|
||||||
//// val activityStack = ActivityManager.getActivityStack()
|
|
||||||
//// activityStack.forEach {
|
|
||||||
//// if (it !is SelectDishActivity && it !is SamplingListActivity) {
|
|
||||||
//// it.finish()
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
// }
|
|
||||||
// }.onFailure {
|
|
||||||
// it.printStackTrace()
|
|
||||||
// toast("数据提交失败")
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private fun loadQualitySpan(isClicked: Boolean = false, isEnable: Boolean = true) {
|
private fun loadQualitySpan(isClicked: Boolean = false, isEnable: Boolean = true) {
|
||||||
binding.rbModeQuality.text =
|
binding.rbModeQuality.text =
|
||||||
@@ -257,7 +238,7 @@ class DeviceSettingActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun saveSeasoning(entity: SeasoningEntity) {
|
fun saveSeasoning(entity: SeasoningEntity) {
|
||||||
appViewModel.saveSeasoning(entity){
|
appViewModel.saveSeasoning(entity) {
|
||||||
toast("保存成功")
|
toast("保存成功")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,19 +33,22 @@ class FoodSearchActivity : BaseActivity() {
|
|||||||
const val PAGE_TYPE = "pageType"
|
const val PAGE_TYPE = "pageType"
|
||||||
const val FOOD_ID = "foodId"
|
const val FOOD_ID = "foodId"
|
||||||
const val FOOD_NAME = "foodName"
|
const val FOOD_NAME = "foodName"
|
||||||
|
const val DINNER_TYPE = "dinnerType"
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var binding: ActivityFoodSearchBinding
|
private lateinit var binding: ActivityFoodSearchBinding
|
||||||
|
|
||||||
private var list: MutableList<FoodRecord> = mutableListOf()
|
private var list: MutableList<FoodRecord> = mutableListOf()
|
||||||
private var pageType = 0
|
private var pageType = 0
|
||||||
|
private var dinnerType = "0"
|
||||||
private val recordAdapter by lazy {
|
private val recordAdapter by lazy {
|
||||||
FoodRecordAdapter(list).apply {
|
FoodRecordAdapter(list).apply {
|
||||||
isStateViewEnable = true
|
isStateViewEnable = true
|
||||||
setOnItemClickListener { adapter, view, position ->
|
setOnItemClickListener { adapter, view, position ->
|
||||||
if (pageType == 1) {
|
if (pageType == 1) {
|
||||||
|
val jumpItem = list[position].also { it.dinnerType = dinnerType }
|
||||||
startActivity<PrepareCookActivity> {
|
startActivity<PrepareCookActivity> {
|
||||||
putExtra(PrepareCookActivity.FOOD_ITEM, list[position] as Serializable)
|
putExtra(PrepareCookActivity.FOOD_ITEM, jumpItem as Serializable)
|
||||||
}
|
}
|
||||||
return@setOnItemClickListener
|
return@setOnItemClickListener
|
||||||
}
|
}
|
||||||
@@ -65,6 +68,7 @@ class FoodSearchActivity : BaseActivity() {
|
|||||||
binding = ActivityFoodSearchBinding.inflate(layoutInflater)
|
binding = ActivityFoodSearchBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
pageType = intent.getIntExtra(PAGE_TYPE, 0)
|
pageType = intent.getIntExtra(PAGE_TYPE, 0)
|
||||||
|
dinnerType = intent.getStringExtra(DINNER_TYPE)?:"0"
|
||||||
setHeaderBackground()
|
setHeaderBackground()
|
||||||
foodName = intent.getStringExtra(FOOD_NAME)
|
foodName = intent.getStringExtra(FOOD_NAME)
|
||||||
binding.etInputDish.setText(foodName)
|
binding.etInputDish.setText(foodName)
|
||||||
@@ -131,16 +135,26 @@ class FoodSearchActivity : BaseActivity() {
|
|||||||
|
|
||||||
private var pageNo = 1
|
private var pageNo = 1
|
||||||
private var pageSize = 100
|
private var pageSize = 100
|
||||||
|
fun getDinnerTypeText(): String {
|
||||||
|
return when (dinnerType) {
|
||||||
|
"1" -> "早餐"
|
||||||
|
"2" -> "午餐"
|
||||||
|
"3" -> "晚餐"
|
||||||
|
else -> "早餐"
|
||||||
|
}
|
||||||
|
}
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
private fun queryListInfo(input: String) {
|
private fun queryListInfo(input: String) {
|
||||||
showLoading()
|
showLoading()
|
||||||
val map = mapOf(
|
val map = mutableMapOf(
|
||||||
"foodName" to input.trim(),
|
"foodName" to input.trim(),
|
||||||
"pageNo" to "$pageNo",
|
"pageNo" to "$pageNo",
|
||||||
"pageSize" to "$pageSize",
|
"pageSize" to "$pageSize",
|
||||||
"canteenId" to BaseApp.canteenId
|
"canteenId" to BaseApp.canteenId
|
||||||
)
|
)
|
||||||
|
if (dinnerType.toInt() > 0) {
|
||||||
|
map["dinnerType"] = getDinnerTypeText()
|
||||||
|
}
|
||||||
val sb = StringBuilder(UrlConfig.QUERY_FOOD_LIST).apply {
|
val sb = StringBuilder(UrlConfig.QUERY_FOOD_LIST).apply {
|
||||||
append("?")
|
append("?")
|
||||||
map.forEach { (key, value) -> append("$key=$value&") }
|
map.forEach { (key, value) -> append("$key=$value&") }
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class HomeActivity : BaseActivity() {
|
|||||||
// appViewModel.updateGoods(it)
|
// appViewModel.updateGoods(it)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// appViewModel.deleteAll()
|
// appViewModel.clearAllSeasoning()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import com.shuwei.dish.match.utils.SwipeCallback
|
|||||||
import com.shuwei.dish.match.utils.WeightUtil
|
import com.shuwei.dish.match.utils.WeightUtil
|
||||||
import com.shuwei.dish.match.utils.ext.clickWithDebounce
|
import com.shuwei.dish.match.utils.ext.clickWithDebounce
|
||||||
import com.shuwei.dish.match.utils.ext.gone
|
import com.shuwei.dish.match.utils.ext.gone
|
||||||
|
import com.shuwei.dish.match.utils.ext.startActivity
|
||||||
import com.shuwei.dish.match.utils.ext.toJsonString
|
import com.shuwei.dish.match.utils.ext.toJsonString
|
||||||
import com.shuwei.dish.match.utils.ext.toObject
|
import com.shuwei.dish.match.utils.ext.toObject
|
||||||
import com.shuwei.dish.match.utils.ext.toast
|
import com.shuwei.dish.match.utils.ext.toast
|
||||||
@@ -147,11 +148,10 @@ class PrepareCookActivity : BaseActivity() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
Log.d(TAG, "goToSubmit: goodsList:${goodsList?.toJsonString()}")
|
Log.d(TAG, "goToSubmit: goodsList:${goodsList?.toJsonString()}")
|
||||||
startActivity(
|
startActivity<SubmitDishActivity> {
|
||||||
Intent(this, SubmitDishActivity::class.java)
|
putExtra(SubmitDishActivity.GOODS_LIST, goodsList as Serializable)
|
||||||
.putExtra(SubmitDishActivity.GOODS_LIST, goodsList as Serializable)
|
putExtra(SubmitDishActivity.FOOD_ITEM, food as Serializable)
|
||||||
.putExtra(SubmitDishActivity.FOOD_ITEM, food as Serializable)
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getGoodsList() {
|
private fun getGoodsList() {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
|||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import com.shuwei.dish.match.R
|
import com.shuwei.dish.match.R
|
||||||
import com.shuwei.dish.match.base.BaseActivity
|
import com.shuwei.dish.match.base.BaseActivity
|
||||||
@@ -25,10 +26,20 @@ class SelectDishActivity : BaseActivity() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val IS_COOKING = "isCooking"
|
const val IS_COOKING = "isCooking"
|
||||||
|
const val DINNER_TYPE = "dinnerType"
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var binding: ActivitySelectDishBinding
|
private lateinit var binding: ActivitySelectDishBinding
|
||||||
private var dishListFragment: DishListFragment? = null
|
|
||||||
|
private lateinit var appViewModel: AppViewModel
|
||||||
|
|
||||||
|
private var dinnerType: String = "1"
|
||||||
|
|
||||||
|
private val fragmentList = mutableListOf<DishListFragment>().apply {
|
||||||
|
add(DishListFragment.instance("1"))
|
||||||
|
add(DishListFragment.instance("2"))
|
||||||
|
add(DishListFragment.instance("3"))
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@@ -55,10 +66,6 @@ class SelectDishActivity : BaseActivity() {
|
|||||||
loadFragment()
|
loadFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var appViewModel: AppViewModel
|
|
||||||
|
|
||||||
var dinnerType: String = "早餐"
|
|
||||||
|
|
||||||
private fun initViewModel() {
|
private fun initViewModel() {
|
||||||
val db = BaseApp.instance!!.database
|
val db = BaseApp.instance!!.database
|
||||||
val factory =
|
val factory =
|
||||||
@@ -68,24 +75,19 @@ class SelectDishActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getCookFoodList(action: (MutableList<CookFoodEntity>?) -> Unit) {
|
fun getCookFoodList(action: (MutableList<CookFoodEntity>?) -> Unit) {
|
||||||
appViewModel.getCookFoodList(cookMode = 0) { action(it) }
|
appViewModel.getCookFoodList(cookMode = 0, dinnerType = dinnerType) { action(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addViewListener() {
|
fun addViewListener() {
|
||||||
binding.dishRadioGroup.setOnCheckedChangeListener { _, checkedId ->
|
binding.dishRadioGroup.setOnCheckedChangeListener { _, checkedId ->
|
||||||
dinnerType = when (checkedId) {
|
dinnerType = when (checkedId) {
|
||||||
R.id.rbBreakfast -> "早餐"
|
R.id.rbBreakfast -> "1"
|
||||||
R.id.rbLunch -> "午餐"
|
R.id.rbLunch -> "2"
|
||||||
R.id.rbDinner -> "晚餐"
|
R.id.rbDinner -> "3"
|
||||||
else -> ""
|
else -> "1"
|
||||||
}
|
}
|
||||||
dishListFragment?.getDishList(1, false)
|
loadFragment()
|
||||||
}
|
}
|
||||||
// binding.llSearchBar.setOnClickListener {
|
|
||||||
// startActivity<FoodSearchActivity> {
|
|
||||||
// putExtra(FoodSearchActivity.PAGE_TYPE, 1)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
binding.etInputDish.addOnActionSearchListener {
|
binding.etInputDish.addOnActionSearchListener {
|
||||||
jumpSearch()
|
jumpSearch()
|
||||||
}
|
}
|
||||||
@@ -102,18 +104,26 @@ class SelectDishActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
startActivity<FoodSearchActivity> {
|
startActivity<FoodSearchActivity> {
|
||||||
putExtra(FoodSearchActivity.PAGE_TYPE, 1)
|
putExtra(FoodSearchActivity.PAGE_TYPE, 1)
|
||||||
|
putExtra(FoodSearchActivity.DINNER_TYPE, dinnerType)
|
||||||
putExtra(FoodSearchActivity.FOOD_NAME, searchText)
|
putExtra(FoodSearchActivity.FOOD_NAME, searchText)
|
||||||
}
|
}
|
||||||
KeyboardUtil.hideKeyboard(this, binding.etInputDish)
|
KeyboardUtil.hideKeyboard(this, binding.etInputDish)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadFragment() {
|
private fun loadFragment() {
|
||||||
DishListFragment.instance().let {
|
runCatching {
|
||||||
dishListFragment = it
|
fragmentList[dinnerType.toInt() - 1].let {
|
||||||
supportFragmentManager.beginTransaction().apply {
|
supportFragmentManager.beginTransaction().apply {
|
||||||
replace(R.id.flSubPage, it)
|
if (fragmentList.contains(it)) {
|
||||||
commit()
|
replace(R.id.flSubPage, it)
|
||||||
|
} else {
|
||||||
|
add(R.id.flSubPage, it)
|
||||||
|
}
|
||||||
|
commit()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}.onFailure {
|
||||||
|
it.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,8 +133,20 @@ class SelectDishActivity : BaseActivity() {
|
|||||||
|
|
||||||
override fun onNewIntent(intent: Intent?) {
|
override fun onNewIntent(intent: Intent?) {
|
||||||
super.onNewIntent(intent)
|
super.onNewIntent(intent)
|
||||||
val isCooking = intent?.getBooleanExtra(IS_COOKING, false) ?: false
|
runCatching {
|
||||||
dishListFragment?.getDishList(1, isCooking)
|
val isCooking = intent?.getBooleanExtra(IS_COOKING, false) ?: false
|
||||||
|
val lastDinnerType = intent?.getStringExtra(DINNER_TYPE) ?: "0"
|
||||||
|
if (lastDinnerType == "1" || lastDinnerType == "2" || lastDinnerType == "3") {
|
||||||
|
fragmentList[lastDinnerType.toInt() - 1].getDishList(1, lastDinnerType)
|
||||||
|
}
|
||||||
|
when(lastDinnerType) {
|
||||||
|
"1"->binding.dishRadioGroup.check(R.id.rbBreakfast)
|
||||||
|
"2"->binding.dishRadioGroup.check(R.id.rbLunch)
|
||||||
|
"3"->binding.dishRadioGroup.check(R.id.rbDinner)
|
||||||
|
}
|
||||||
|
}.onFailure {
|
||||||
|
it.printStackTrace()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Deprecated in Java")
|
@Deprecated("Deprecated in Java")
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ class SubmitDishActivity : BaseActivity() {
|
|||||||
foodId = it.foodId ?: ""
|
foodId = it.foodId ?: ""
|
||||||
foodName = it.foodName
|
foodName = it.foodName
|
||||||
cookMode = it.cookMode
|
cookMode = it.cookMode
|
||||||
|
dinnerType = it.dinnerType
|
||||||
}
|
}
|
||||||
canteenId = BaseApp.canteenId
|
canteenId = BaseApp.canteenId
|
||||||
}
|
}
|
||||||
@@ -96,7 +97,7 @@ class SubmitDishActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun loadSeasoningFromLocal() {
|
private fun loadSeasoningFromLocal() {
|
||||||
appViewModel.getCookFoodGoodsList(food?.foodId!!) { it ->
|
appViewModel.getCookFoodGoodsList(foodId = food!!.foodId!!, cookMode = food!!.cookMode) { it ->
|
||||||
goodsList = mutableListOf()
|
goodsList = mutableListOf()
|
||||||
//设置主辅材数据
|
//设置主辅材数据
|
||||||
goodsList?.addAll(it.filter { goods -> goods.materialType != 3 })
|
goodsList?.addAll(it.filter { goods -> goods.materialType != 3 })
|
||||||
@@ -174,12 +175,12 @@ class SubmitDishActivity : BaseActivity() {
|
|||||||
// return@addWeightListener
|
// return@addWeightListener
|
||||||
// }
|
// }
|
||||||
val firstWeight = firstGoodsArray.get(address, null)
|
val firstWeight = firstGoodsArray.get(address, null)
|
||||||
if (firstWeight != weight) {
|
// if (firstWeight != weight) {
|
||||||
Log.d(
|
// Log.d(
|
||||||
TAG,
|
// TAG,
|
||||||
"addViewListener: state=$state,address=$address,weight=$weight,firstWeight=$firstWeight"
|
// "addViewListener: state=$state,address=$address,weight=$weight,firstWeight=$firstWeight"
|
||||||
)
|
// )
|
||||||
}
|
// }
|
||||||
if (firstWeight == null) {
|
if (firstWeight == null) {
|
||||||
//未设置数据
|
//未设置数据
|
||||||
firstGoodsArray.put(address, weight)
|
firstGoodsArray.put(address, weight)
|
||||||
@@ -273,7 +274,14 @@ class SubmitDishActivity : BaseActivity() {
|
|||||||
val typeToken = object : TypeToken<List<CookFoodGoodsEntity>>() {}
|
val typeToken = object : TypeToken<List<CookFoodGoodsEntity>>() {}
|
||||||
val tempSeasoningList = seasoningJson.toType(typeToken = typeToken)
|
val tempSeasoningList = seasoningJson.toType(typeToken = typeToken)
|
||||||
goodsList?.addAll(tempSeasoningList)
|
goodsList?.addAll(tempSeasoningList)
|
||||||
|
cookFoodEntity.let {
|
||||||
|
it.dinnerType = when (it.dinnerType) {
|
||||||
|
"早餐" -> "1"
|
||||||
|
"午餐" -> "2"
|
||||||
|
"晚餐" -> "3"
|
||||||
|
else -> it.dinnerType
|
||||||
|
}
|
||||||
|
}
|
||||||
val isSamplingData = food!!.cookMode == 1
|
val isSamplingData = food!!.cookMode == 1
|
||||||
if (isSamplingData) {
|
if (isSamplingData) {
|
||||||
//生成临时foodId,解决采样模式没有foodId,无法关联数据的问题
|
//生成临时foodId,解决采样模式没有foodId,无法关联数据的问题
|
||||||
@@ -325,7 +333,16 @@ class SubmitDishActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cookFoodEntity.stFoodInfoConstituteList = this@SubmitDishActivity.goodsList
|
cookFoodEntity.let {
|
||||||
|
it.stFoodInfoConstituteList = this@SubmitDishActivity.goodsList
|
||||||
|
it.dinnerType = when(it.dinnerType) {
|
||||||
|
"1" -> "早餐"
|
||||||
|
"2" -> "午餐"
|
||||||
|
"3" -> "晚餐"
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val isSamplingData = food!!.cookMode == 1
|
val isSamplingData = food!!.cookMode == 1
|
||||||
if (isSamplingData) {
|
if (isSamplingData) {
|
||||||
//采样模式没有foodId
|
//采样模式没有foodId
|
||||||
@@ -373,6 +390,7 @@ class SubmitDishActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
startActivity<SelectDishActivity> {
|
startActivity<SelectDishActivity> {
|
||||||
putExtra(SelectDishActivity.IS_COOKING, isCooking)
|
putExtra(SelectDishActivity.IS_COOKING, isCooking)
|
||||||
|
putExtra(SelectDishActivity.DINNER_TYPE, food?.dinnerType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import android.view.ViewGroup
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import com.chad.library.adapter4.util.setOnDebouncedItemClick
|
||||||
import com.shuwei.dish.match.adapter.DishShowAdapter
|
import com.shuwei.dish.match.adapter.DishShowAdapter
|
||||||
import com.shuwei.dish.match.base.BaseApp
|
import com.shuwei.dish.match.base.BaseApp
|
||||||
import com.shuwei.dish.match.databinding.FragmentDishListBinding
|
import com.shuwei.dish.match.databinding.FragmentDishListBinding
|
||||||
@@ -32,27 +33,29 @@ class DishListFragment : Fragment() {
|
|||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "DishListFragment"
|
private const val TAG = "DishListFragment"
|
||||||
|
|
||||||
// const val DINNER_TYPE = "dinnerType"
|
const val DINNER_TYPE = "dinnerType"
|
||||||
public fun instance(): DishListFragment {
|
public fun instance(dinnerType: String): DishListFragment {
|
||||||
return DishListFragment().apply {
|
return DishListFragment().apply {
|
||||||
// arguments = Bundle().apply {
|
arguments = Bundle().apply {
|
||||||
// putInt(DINNER_TYPE, type)
|
putString(DINNER_TYPE, dinnerType)
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private var dinnerType = ""
|
|
||||||
private var pageNo = 1
|
private var pageNo = 1
|
||||||
private val pageSize = 30
|
private val pageSize = 30
|
||||||
|
|
||||||
private lateinit var activity: SelectDishActivity
|
private lateinit var activity: SelectDishActivity
|
||||||
|
|
||||||
|
private lateinit var binding: FragmentDishListBinding
|
||||||
|
|
||||||
|
private var dinnerType = "0"
|
||||||
|
|
||||||
private var list: MutableList<FoodRecord> = mutableListOf()
|
private var list: MutableList<FoodRecord> = mutableListOf()
|
||||||
private val dishAdapter by lazy {
|
private val dishAdapter by lazy {
|
||||||
DishShowAdapter(list = list).apply {
|
DishShowAdapter(list = list).apply {
|
||||||
isStateViewEnable = true
|
isStateViewEnable = true
|
||||||
setOnItemClickListener { adapter, view, position ->
|
setOnDebouncedItemClick { adapter, view, position ->
|
||||||
val item = list[position]
|
val item = list[position]
|
||||||
if (item.isCooking) {
|
if (item.isCooking) {
|
||||||
//烹饪中,跳到称熟重页面
|
//烹饪中,跳到称熟重页面
|
||||||
@@ -62,8 +65,9 @@ class DishListFragment : Fragment() {
|
|||||||
item as Serializable
|
item as Serializable
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return@setOnItemClickListener
|
return@setOnDebouncedItemClick
|
||||||
}
|
}
|
||||||
|
item.dinnerType = dinnerType
|
||||||
context.startActivity<PrepareCookActivity> {
|
context.startActivity<PrepareCookActivity> {
|
||||||
putExtra(
|
putExtra(
|
||||||
SubmitDishActivity.FOOD_ITEM,
|
SubmitDishActivity.FOOD_ITEM,
|
||||||
@@ -75,8 +79,6 @@ class DishListFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var binding: FragmentDishListBinding
|
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
@@ -89,7 +91,7 @@ class DishListFragment : Fragment() {
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
activity = requireActivity() as SelectDishActivity
|
activity = requireActivity() as SelectDishActivity
|
||||||
//toast("type=$type")
|
dinnerType = arguments?.getString(DINNER_TYPE, "0")?:"0"
|
||||||
binding.rvDishList.run {
|
binding.rvDishList.run {
|
||||||
layoutManager =
|
layoutManager =
|
||||||
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||||
@@ -127,19 +129,28 @@ class DishListFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fun getDishList(pageNo: Int, dinnerType: String) {
|
||||||
fun getDishList(pageNo: Int, isCooking: Boolean) {
|
|
||||||
this.pageNo = pageNo
|
this.pageNo = pageNo
|
||||||
|
this.dinnerType = dinnerType
|
||||||
getDishList()
|
getDishList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getDinnerTypeText(): String {
|
||||||
|
return when (dinnerType) {
|
||||||
|
"1" -> "早餐"
|
||||||
|
"2" -> "午餐"
|
||||||
|
"3" -> "晚餐"
|
||||||
|
else -> "早餐"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
@Suppress("unchecked_cast")
|
@Suppress("unchecked_cast")
|
||||||
fun getDishList() {
|
fun getDishList() {
|
||||||
activity.showLoading()
|
activity.showLoading()
|
||||||
val map = mapOf(
|
val map = mapOf(
|
||||||
// "foodName" to input,
|
// "foodName" to input,
|
||||||
"dinnerType" to activity.dinnerType,
|
"dinnerType" to getDinnerTypeText(),
|
||||||
"pageNo" to "$pageNo",
|
"pageNo" to "$pageNo",
|
||||||
"pageSize" to "$pageSize",
|
"pageSize" to "$pageSize",
|
||||||
"canteenId" to BaseApp.canteenId
|
"canteenId" to BaseApp.canteenId
|
||||||
@@ -231,6 +242,7 @@ class DishListFragment : Fragment() {
|
|||||||
if (food != null) {
|
if (food != null) {
|
||||||
food.isCooking = true
|
food.isCooking = true
|
||||||
food.sort = index
|
food.sort = index
|
||||||
|
food.dinnerType = entity.dinnerType?:"0"
|
||||||
tempList.add(food)
|
tempList.add(food)
|
||||||
} else {
|
} else {
|
||||||
//当前查询到的list不包括本地数据id,可能数据在很多页以后了,暂时只能直接构造数据
|
//当前查询到的list不包括本地数据id,可能数据在很多页以后了,暂时只能直接构造数据
|
||||||
@@ -239,6 +251,7 @@ class DishListFragment : Fragment() {
|
|||||||
foodId = entity.foodId,
|
foodId = entity.foodId,
|
||||||
foodName = entity.foodName,
|
foodName = entity.foodName,
|
||||||
sort = index,
|
sort = index,
|
||||||
|
dinnerType = entity.dinnerType?:"0",
|
||||||
isCooking = true
|
isCooking = true
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.shuwei.dish.match.utils
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import org.json.JSONObject
|
||||||
|
import java.io.BufferedReader
|
||||||
|
import java.io.InputStreamReader
|
||||||
|
|
||||||
|
object JsonAssetsLoader {
|
||||||
|
// 方法1:使用BufferedReader逐行读取(适合大文件)
|
||||||
|
fun loadJsonFromAssets(context: Context, fileName: String): String {
|
||||||
|
val stringBuilder = StringBuilder()
|
||||||
|
try {
|
||||||
|
context.assets.open(fileName).use { inputStream ->
|
||||||
|
BufferedReader(InputStreamReader(inputStream)).use { reader ->
|
||||||
|
var line: String?
|
||||||
|
while (reader.readLine().also { line = it } != null) {
|
||||||
|
stringBuilder.append(line)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
return stringBuilder.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 方法2:使用Gson解析到数据类
|
||||||
|
inline fun <reified T> parseJsonFromAssets(
|
||||||
|
context: Context,
|
||||||
|
fileName: String
|
||||||
|
): T? {
|
||||||
|
return try {
|
||||||
|
Gson().fromJson(
|
||||||
|
loadJsonFromAssets(context, fileName),
|
||||||
|
T::class.java
|
||||||
|
)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 方法3:使用原生JSONObject解析
|
||||||
|
fun getJsonObjectFromAssets(
|
||||||
|
context: Context,
|
||||||
|
fileName: String
|
||||||
|
): JSONObject? {
|
||||||
|
return try {
|
||||||
|
JSONObject(loadJsonFromAssets(context, fileName))
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.shuwei.dish.match.utils
|
||||||
|
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
|
import android.os.SystemClock
|
||||||
|
import android.view.View
|
||||||
|
import java.util.Arrays
|
||||||
|
|
||||||
|
class MultiClickDetector(private val targetCount: Int = 10,
|
||||||
|
private val intervalMs: Long = 500) {
|
||||||
|
private var clickCount = 0
|
||||||
|
private val clickTimestamps = LongArray(targetCount)
|
||||||
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
|
private lateinit var callback: () -> Unit
|
||||||
|
|
||||||
|
fun setOnMultiClickListener(view: View, action: () -> Unit) {
|
||||||
|
callback = action
|
||||||
|
view.setOnClickListener {
|
||||||
|
System.arraycopy(clickTimestamps, 1, clickTimestamps, 0, targetCount - 1)
|
||||||
|
clickTimestamps[targetCount - 1] = SystemClock.uptimeMillis()
|
||||||
|
|
||||||
|
if (clickTimestamps[0] >= SystemClock.uptimeMillis() - intervalMs) {
|
||||||
|
callback.invoke()
|
||||||
|
resetCount()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用Handler的延迟检测方案
|
||||||
|
fun setOnDelayedMultiClickListener(view: View, action: () -> Unit) {
|
||||||
|
callback = action
|
||||||
|
view.setOnClickListener {
|
||||||
|
clickCount++
|
||||||
|
handler.removeCallbacks(resetTask)
|
||||||
|
handler.postDelayed(resetTask, intervalMs)
|
||||||
|
|
||||||
|
if (clickCount >= targetCount) {
|
||||||
|
callback.invoke()
|
||||||
|
resetCount()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val resetTask = Runnable { resetCount() }
|
||||||
|
private fun resetCount() {
|
||||||
|
clickCount = 0
|
||||||
|
Arrays.fill(clickTimestamps, 0L)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,6 +32,9 @@ class SwipeCallback(
|
|||||||
viewHolder: RecyclerView.ViewHolder
|
viewHolder: RecyclerView.ViewHolder
|
||||||
): Int {
|
): Int {
|
||||||
val position = viewHolder.getBindingAdapterPosition()
|
val position = viewHolder.getBindingAdapterPosition()
|
||||||
|
if (position < 0) {
|
||||||
|
return makeMovementFlags(0, 0)
|
||||||
|
}
|
||||||
// 默认的拖动和滑动方向
|
// 默认的拖动和滑动方向
|
||||||
val dragFlags = 0
|
val dragFlags = 0
|
||||||
// ItemTouchHelper.UP or ItemTouchHelper.DOWN
|
// ItemTouchHelper.UP or ItemTouchHelper.DOWN
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import android.os.Build
|
|||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.util.SparseIntArray
|
||||||
import com.aithings.Weigher
|
import com.aithings.Weigher
|
||||||
import com.shuwei.dish.match.base.BaseApp
|
import com.shuwei.dish.match.base.BaseApp
|
||||||
import com.shuwei.dish.match.utils.ext.toast
|
import com.shuwei.dish.match.utils.ext.toast
|
||||||
@@ -11,6 +12,8 @@ import com.wabon.wbintelligenthardwaresdk.api.SensorScale
|
|||||||
|
|
||||||
object WeightUtil {
|
object WeightUtil {
|
||||||
|
|
||||||
|
val weightArray = SparseIntArray()
|
||||||
|
|
||||||
fun connect(initCallback: (connect: Boolean) -> Unit) {
|
fun connect(initCallback: (connect: Boolean) -> Unit) {
|
||||||
Weigher.setListener(object : WeightListenerImpl() {
|
Weigher.setListener(object : WeightListenerImpl() {
|
||||||
override fun onInit(connect: Boolean) {
|
override fun onInit(connect: Boolean) {
|
||||||
@@ -39,7 +42,8 @@ object WeightUtil {
|
|||||||
else -> ""
|
else -> ""
|
||||||
}
|
}
|
||||||
val result1 = String.format("$stateStr 重量:%s kg", weight / 1000f)
|
val result1 = String.format("$stateStr 重量:%s kg", weight / 1000f)
|
||||||
Log.d("WeightUtil", "ttlReturn, address:$address,$result1")
|
//Log.d("WeightUtil", "ttlReturn, address:$address,$result1")
|
||||||
|
weightArray.put(address, weight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ fun EditText.addOnActionSearchListener(searchCallback: () -> Unit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun View.clickWithDebounce(delay: Long = 500, action: () -> Unit) {
|
fun View.clickWithDebounce(delay: Long = 300, action: () -> Unit) {
|
||||||
var job: Job? = null
|
var job: Job? = null
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
job?.cancel()
|
job?.cancel()
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
package com.shuwei.dish.match.viewmodel
|
package com.shuwei.dish.match.viewmodel
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.shuwei.dish.match.base.BaseApp
|
|
||||||
import com.shuwei.dish.match.db.AppRepository
|
import com.shuwei.dish.match.db.AppRepository
|
||||||
import com.shuwei.dish.match.entity.CookFoodEntity
|
import com.shuwei.dish.match.entity.CookFoodEntity
|
||||||
import com.shuwei.dish.match.entity.CookFoodGoodsEntity
|
import com.shuwei.dish.match.entity.CookFoodGoodsEntity
|
||||||
import com.shuwei.dish.match.entity.SeasoningEntity
|
import com.shuwei.dish.match.entity.SeasoningEntity
|
||||||
import com.shuwei.dish.match.utils.ext.toast
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlin.collections.forEach
|
import kotlin.collections.forEach
|
||||||
|
|
||||||
@@ -28,9 +24,13 @@ class AppViewModel(private val rep: AppRepository) : ViewModel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCookFoodList(cookMode: Int, action: (MutableList<CookFoodEntity>?) -> Unit) {
|
fun getCookFoodList(
|
||||||
|
cookMode: Int,
|
||||||
|
dinnerType: String = "0",
|
||||||
|
action: (MutableList<CookFoodEntity>?) -> Unit
|
||||||
|
) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val data = rep.getCookFoodList(cookMode)
|
val data = rep.getCookFoodList(cookMode, dinnerType)
|
||||||
action(data)
|
action(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,13 +64,15 @@ class AppViewModel(private val rep: AppRepository) : ViewModel() {
|
|||||||
if (data != null) {
|
if (data != null) {
|
||||||
//存在数据删除
|
//存在数据删除
|
||||||
rep.deleteCookFood(entity.foodId, cookMode)
|
rep.deleteCookFood(entity.foodId, cookMode)
|
||||||
rep.deleteCookFoodGoodsList(entity.foodId)
|
rep.deleteCookFoodGoodsList(data.id, entity.foodId)
|
||||||
}
|
}
|
||||||
//重新保存数据
|
//重新保存数据
|
||||||
rep.insertCookFood(entity)
|
rep.insertCookFood(entity)
|
||||||
|
val newData = rep.getCookFoodById(entity.foodId, cookMode)
|
||||||
list?.let { it ->
|
list?.let { it ->
|
||||||
it.forEach { goods->
|
it.forEach { goods ->
|
||||||
goods.id = 0
|
goods.id = 0
|
||||||
|
goods.pid = newData?.id?:0
|
||||||
}
|
}
|
||||||
rep.insertGoodsList(it)
|
rep.insertGoodsList(it)
|
||||||
}
|
}
|
||||||
@@ -84,8 +86,11 @@ class AppViewModel(private val rep: AppRepository) : ViewModel() {
|
|||||||
onFinish: () -> Unit
|
onFinish: () -> Unit
|
||||||
) {
|
) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
rep.deleteCookFood(foodId = foodId, cookMode = cookMode)
|
val data = rep.getCookFoodById(foodId, cookMode)
|
||||||
rep.deleteCookFoodGoodsList(foodId)
|
if (data != null) {
|
||||||
|
rep.deleteCookFood(foodId = foodId, cookMode = cookMode)
|
||||||
|
rep.deleteCookFoodGoodsList(pid = data.id, foodId = foodId)
|
||||||
|
}
|
||||||
onFinish()
|
onFinish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,50 +100,54 @@ class AppViewModel(private val rep: AppRepository) : ViewModel() {
|
|||||||
|
|
||||||
fun getCookFoodGoodsList(
|
fun getCookFoodGoodsList(
|
||||||
foodId: String,
|
foodId: String,
|
||||||
|
cookMode: Int,
|
||||||
action: (list: MutableList<CookFoodGoodsEntity>) -> Unit
|
action: (list: MutableList<CookFoodGoodsEntity>) -> Unit
|
||||||
) {
|
) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val list = rep.getCookFoodGoodsList(foodId)
|
val cookFood = rep.getCookFoodById(foodId, cookMode)
|
||||||
action(list)
|
cookFood?.let {
|
||||||
|
val list = rep.getCookFoodGoodsList(pid = it.id, foodId = it.foodId)
|
||||||
|
action(list)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateGoods(entity: CookFoodGoodsEntity) {
|
// fun updateGoods(entity: CookFoodGoodsEntity) {
|
||||||
viewModelScope.launch {
|
// viewModelScope.launch {
|
||||||
rep.updateGoods(entity)
|
// rep.updateGoods(entity)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
fun saveCookFoodGoods(list: MutableList<CookFoodGoodsEntity>) {
|
// fun saveCookFoodGoods(list: MutableList<CookFoodGoodsEntity>) {
|
||||||
viewModelScope.launch {
|
// viewModelScope.launch {
|
||||||
val foodId = list[0].foodId
|
// val foodId = list[0].foodId
|
||||||
val data: MutableList<CookFoodGoodsEntity>? =
|
// val data: MutableList<CookFoodGoodsEntity>? =
|
||||||
rep.getCookFoodGoodsList(foodId!!)
|
// rep.getCookFoodGoodsList(foodId!!)
|
||||||
if (data.isNullOrEmpty()) {
|
// if (data.isNullOrEmpty()) {
|
||||||
rep.insertGoodsList(list)
|
// rep.insertGoodsList(list)
|
||||||
return@launch
|
// return@launch
|
||||||
}
|
// }
|
||||||
val localDbSeasoningList = rep.getCookFoodGoodsListByType(foodId, 3)
|
// val localDbSeasoningList = rep.getCookFoodGoodsListByType(foodId, 3)
|
||||||
localDbSeasoningList.forEach {
|
// localDbSeasoningList.forEach {
|
||||||
it.isDel = 1
|
// it.isDel = 1
|
||||||
//更新本地调料数据为已删除的状态
|
// //更新本地调料数据为已删除的状态
|
||||||
rep.updateGoods(it)
|
// rep.updateGoods(it)
|
||||||
}
|
// }
|
||||||
//筛选出调料数据保存,主辅材不会变更不需要再次处理
|
// //筛选出调料数据保存,主辅材不会变更不需要再次处理
|
||||||
val saveSeasoningList = list.filter { it.materialType == 3 }
|
// val saveSeasoningList = list.filter { it.materialType == 3 }
|
||||||
rep.insertGoodsList(saveSeasoningList.toMutableList())
|
// rep.insertGoodsList(saveSeasoningList.toMutableList())
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
fun addSeasoning(list: MutableList<SeasoningEntity>, callback: () -> Unit) {
|
// fun addSeasoning(list: MutableList<SeasoningEntity>, callback: () -> Unit) {
|
||||||
viewModelScope.launch {
|
// viewModelScope.launch {
|
||||||
rep.deleteBatch()
|
// rep.deleteBatch()
|
||||||
rep.insertSeasoningList(items = list)
|
// rep.insertSeasoningList(items = list)
|
||||||
callback()
|
// callback()
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private var isProcessing = false
|
private var isProcessing = false
|
||||||
fun loadSeasoning(action: (list: MutableList<SeasoningEntity>) -> Unit) {
|
fun loadSeasoning(action: (list: MutableList<SeasoningEntity>) -> Unit) {
|
||||||
@@ -157,9 +166,11 @@ class AppViewModel(private val rep: AppRepository) : ViewModel() {
|
|||||||
rep.deleteEmptySeasoning()
|
rep.deleteEmptySeasoning()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fun deleteAll() {
|
|
||||||
|
fun clearAllSeasoning(action:()->Unit) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
rep.deleteBatch()
|
rep.clearAllSeasoning()
|
||||||
|
action()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +182,7 @@ class AppViewModel(private val rep: AppRepository) : ViewModel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveSeasoning(entity: SeasoningEntity, block:()-> Unit) {
|
fun saveSeasoning(entity: SeasoningEntity, block: () -> Unit) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val seasoning = rep.getSeasoningBySort(entity.sort)
|
val seasoning = rep.getSeasoningBySort(entity.sort)
|
||||||
if (seasoning == null) {
|
if (seasoning == null) {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
android:textSize="28sp" />
|
android:textSize="28sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/tvSetting"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="end|center_vertical"
|
android:layout_gravity="end|center_vertical"
|
||||||
@@ -122,7 +123,6 @@
|
|||||||
android:layout_marginEnd="30dp">
|
android:layout_marginEnd="30dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvSetting"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
|
|||||||
@@ -20,6 +20,9 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="25dp"
|
android:layout_marginTop="25dp"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
android:text="@string/food_remind_02"
|
android:text="@string/food_remind_02"
|
||||||
android:textColor="@color/black999"
|
android:textColor="@color/black999"
|
||||||
android:layout_marginBottom="60dp"
|
android:layout_marginBottom="60dp"
|
||||||
|
|||||||
Reference in New Issue
Block a user