Добавил новое поле Радиус, осталость еще цвет, и вообще супер
This commit is contained in:
parent
ec12fd5cbf
commit
a985333daf
@ -54,6 +54,7 @@ class RestBikeRepository(
|
||||
x.id,
|
||||
x.dateTime,
|
||||
x.weight,
|
||||
x.radius,
|
||||
x.maxCount - service.getRents().flatMap { rent ->
|
||||
rent.items.filter { item -> item.id == x.id }
|
||||
}.sumOf { item -> item.count },
|
||||
|
@ -11,6 +11,7 @@ class ItemFromBikeRemote(
|
||||
@Contextual
|
||||
val dateTime: LocalDateTime = LocalDateTime.MIN,
|
||||
val weight: Double = 0.0,
|
||||
val radius: Double = 0.0,
|
||||
val maxCount: Int = 0,
|
||||
val availableCount: Int = 0,
|
||||
val bikeId: Int = 0,
|
||||
@ -20,6 +21,7 @@ fun ItemFromBikeRemote.toItemFromBike(): ItemFromBike = ItemFromBike(
|
||||
id,
|
||||
dateTime,
|
||||
weight,
|
||||
radius,
|
||||
availableCount,
|
||||
bikeId
|
||||
)
|
||||
@ -28,6 +30,7 @@ fun ItemFromBike.toItemFromBikeRemote(): ItemFromBikeRemote = ItemFromBikeRemote
|
||||
uid,
|
||||
dateTime,
|
||||
weight,
|
||||
radius,
|
||||
availableCount,
|
||||
bikeId
|
||||
)
|
@ -13,7 +13,7 @@ class ItemFromCartRemote(
|
||||
var bikeId: Int = 0,
|
||||
)
|
||||
|
||||
fun ItemFromCartRemote.toItemFromCart(bike: BikeRemote, dateTime: LocalDateTime, weight: Double, availableCount: Int): ItemFromCart =
|
||||
fun ItemFromCartRemote.toItemFromCart(bike: BikeRemote, dateTime: LocalDateTime, weight: Double, radius: Double, availableCount: Int): ItemFromCart =
|
||||
ItemFromCart(
|
||||
id, dateTime, weight, availableCount, count, bike.id, bike.toBike()
|
||||
id, dateTime, weight, radius, availableCount, count, bike.id, bike.toBike()
|
||||
)
|
@ -12,11 +12,12 @@ class ItemFromRentRemote(
|
||||
val id: Int = 0,
|
||||
@Contextual val dateTime: LocalDateTime = LocalDateTime.MIN,
|
||||
val frozenWeight: Double = 0.0,
|
||||
val radius: Double = 0.0,
|
||||
val count: Int = 0,
|
||||
val bikeId: Int = 0,
|
||||
)
|
||||
|
||||
fun ItemFromRentRemote.toItemFromRent(bike: BikeRemote): ItemFromRent =
|
||||
ItemFromRent(
|
||||
id, dateTime, frozenWeight, count, bikeId, bike.toBike()
|
||||
id, dateTime, frozenWeight, radius, count, bikeId, bike.toBike()
|
||||
)
|
@ -11,6 +11,7 @@ data class ItemRemote(
|
||||
@Contextual
|
||||
val dateTime: LocalDateTime,
|
||||
val weight: Double,
|
||||
val radius: Double,
|
||||
val maxCount: Int,
|
||||
val bikeId: Int = 0
|
||||
)
|
||||
@ -19,6 +20,7 @@ fun ItemRemote.toItem(): Item = Item(
|
||||
id,
|
||||
dateTime,
|
||||
weight,
|
||||
radius,
|
||||
maxCount,
|
||||
bikeId
|
||||
)
|
||||
@ -27,6 +29,7 @@ fun Item.toItemRemote(): ItemRemote = ItemRemote(
|
||||
uid,
|
||||
dateTime,
|
||||
weight,
|
||||
radius,
|
||||
maxCount,
|
||||
bikeId
|
||||
)
|
@ -12,6 +12,7 @@ data class ItemWithBikeRemote(
|
||||
@Contextual
|
||||
val dateTime: LocalDateTime,
|
||||
val weight: Double,
|
||||
val radius: Double,
|
||||
val maxCount: Int,
|
||||
val bikeId: Int = 0,
|
||||
val bike: BikeRemote,
|
||||
@ -21,6 +22,7 @@ fun ItemWithBikeRemote.toItem(): Item = Item(
|
||||
id,
|
||||
dateTime,
|
||||
weight,
|
||||
radius,
|
||||
maxCount,
|
||||
bikeId
|
||||
)
|
@ -114,16 +114,17 @@ class RestItemRepository(
|
||||
|
||||
// Отображаем данные в виде таблицы
|
||||
val tableStartY = yTitle + 80f
|
||||
val columnWidths = floatArrayOf(0.5f, 1.5f, 1f, 1.5f, 1f) // Увеличиваем ширину столбцов
|
||||
val columnWidths = floatArrayOf(0.5f, 1.5f, 1f, 0.5f, 1.5f, 1f) // Увеличиваем ширину столбцов
|
||||
val rowHeight = 30f // Увеличиваем высоту строки
|
||||
|
||||
drawTableRow(canvas, arrayOf("ID", "Дата проверки", "Вес", "Количество", "ID велосипеда"), columnWidths, tableStartY, paint)
|
||||
drawTableRow(canvas, arrayOf("ID", "Дата проверки", "Вес", "R", "Количество", "ID велосипеда"), columnWidths, tableStartY, paint)
|
||||
|
||||
for ((index, report) in reportData.withIndex()) {
|
||||
val row = arrayOf(
|
||||
report.id.toString(),
|
||||
report.dateTime.toString(),
|
||||
report.weight.toString(),
|
||||
report.radius.toString(),
|
||||
report.maxCount.toString(),
|
||||
report.bikeId.toString()
|
||||
)
|
||||
|
@ -59,6 +59,7 @@ class RestRentRepository(
|
||||
uid,
|
||||
it.id,
|
||||
it.frozenWeight,
|
||||
it.radius,
|
||||
it.count
|
||||
)
|
||||
)
|
||||
|
@ -19,6 +19,7 @@ class RestRentItemRepository(
|
||||
item.uid,
|
||||
item.dateTime,
|
||||
item.weight,
|
||||
item.radius,
|
||||
rentItemCrossRef.count,
|
||||
item.bikeId
|
||||
)
|
||||
|
@ -7,6 +7,7 @@ data class ReportRemote(
|
||||
val id: Int = 0,
|
||||
val dateTime: Int = 0,
|
||||
val weight: Double = 0.0,
|
||||
val radius: Double = 0.0,
|
||||
val maxCount: Int = 0,
|
||||
val bikeId: Int = 0
|
||||
)
|
@ -53,6 +53,7 @@ class RestUserRepository(
|
||||
item.bike,
|
||||
item.dateTime,
|
||||
item.weight,
|
||||
item.radius,
|
||||
item.maxCount - service.getRents().flatMap { rent ->
|
||||
rent.items.filter { item -> item.id == it.id }
|
||||
}.sumOf { item -> item.count })
|
||||
|
@ -93,6 +93,7 @@ fun Cart(
|
||||
uid = item.uid,
|
||||
dateTime = item.dateTime,
|
||||
weight = item.weight,
|
||||
radius = item.radius,
|
||||
maxCount = 0,
|
||||
bikeId = item.bikeId
|
||||
), user = it
|
||||
@ -108,6 +109,7 @@ fun Cart(
|
||||
uid = item.uid,
|
||||
dateTime = item.dateTime,
|
||||
weight = item.weight,
|
||||
radius = item.radius,
|
||||
maxCount = 0,
|
||||
bikeId = item.bikeId
|
||||
), userId = it, count = count, availableCount = item.availableCount
|
||||
@ -263,6 +265,7 @@ private fun ItemListItem(
|
||||
Text(
|
||||
text = "${item.bike.name}\n" +
|
||||
"Вес: ${item.weight}\n" +
|
||||
"R: ${item.radius}\n" +
|
||||
"${currentCount}/${item.availableCount}\n" +
|
||||
"Год: ${formattedDate}",
|
||||
color = MaterialTheme.colorScheme.onSecondary
|
||||
|
@ -40,6 +40,7 @@ class CartViewModel(
|
||||
rentId.toInt(),
|
||||
item.uid,
|
||||
item.weight,
|
||||
item.radius,
|
||||
item.count
|
||||
)
|
||||
)
|
||||
|
@ -109,7 +109,7 @@ fun ItemList(
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
Text(
|
||||
text = "Вес: ${item.weight}\n" + "Количество: ${item.availableCount}\n" + "Год: ${formattedDate}",
|
||||
text = "Вес: ${item.weight}\n" + "R: ${item.radius}\n" + "Количество: ${item.availableCount}\n" + "Год: ${formattedDate}",
|
||||
color = MaterialTheme.colorScheme.onPrimary
|
||||
)
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ class ItemListViewModel(
|
||||
uid = item.uid,
|
||||
dateTime = item.dateTime,
|
||||
weight = item.weight,
|
||||
radius = item.radius,
|
||||
maxCount = 0,
|
||||
bikeId = 0
|
||||
)
|
||||
|
@ -89,6 +89,7 @@ fun RentView(
|
||||
Text(
|
||||
text = "${item.bike.name}\n" +
|
||||
"Вес: ${item.frozenWeight}\n" +
|
||||
"R: ${item.radius}\n" +
|
||||
"Количество: ${count.value}\n" +
|
||||
"Дата: ${formattedDate}",
|
||||
color = MaterialTheme.colorScheme.onPrimary
|
||||
|
@ -236,7 +236,7 @@ fun ReportPage (navController: NavController?, viewModel: ReportViewModel = view
|
||||
coroutineScope.launch {
|
||||
viewModel.generatePdfFile(
|
||||
context = context,
|
||||
fileName = "отчет.pdf",
|
||||
fileName = "Отчет по велосипедам.pdf",
|
||||
reportData = reportResultPageState.resReport
|
||||
)
|
||||
}
|
||||
@ -303,13 +303,14 @@ fun TableScreen(reportData: List<ReportRemote>) {
|
||||
Text("ID", Modifier.weight(0.5f), color = MaterialTheme.colorScheme.background)
|
||||
Text("Дата", Modifier.weight(1.0f), color = MaterialTheme.colorScheme.background)
|
||||
Text("Вес", Modifier.weight(1.0f), color = MaterialTheme.colorScheme.background)
|
||||
Text("R", Modifier.weight(0.5f), color = MaterialTheme.colorScheme.background)
|
||||
Text("Кол-во", Modifier.weight(1.0f), color = MaterialTheme.colorScheme.background)
|
||||
Text("ID вел.", Modifier.weight(1.0f), color = MaterialTheme.colorScheme.background)
|
||||
}
|
||||
|
||||
// Here are all the lines of your table.
|
||||
reportData.forEach {
|
||||
val (id, dateTime, weight, maxCount, bikeId) = it
|
||||
val (id, dateTime, weight, radius, maxCount, bikeId) = it
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
@ -321,6 +322,7 @@ fun TableScreen(reportData: List<ReportRemote>) {
|
||||
Text(id.toString(), Modifier.weight(0.5f))
|
||||
Text(dateTime.toString(), Modifier.weight(1.0f))
|
||||
Text(weight.toString(), Modifier.weight(1.0f))
|
||||
Text(radius.toString(), Modifier.weight(1.0f))
|
||||
Text(maxCount.toString(), Modifier.weight(1.0f))
|
||||
Text(bikeId.toString(), Modifier.weight(1.0f))
|
||||
}
|
||||
|
@ -127,6 +127,19 @@ private fun ItemEdit(
|
||||
color = MaterialTheme.colorScheme.onSecondary
|
||||
)
|
||||
)
|
||||
OutlinedTextField(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
value = itemUiState.itemDetails.radius,
|
||||
label = { Text(text = "R") },
|
||||
onValueChange = {
|
||||
onUpdate(itemUiState.itemDetails.copy(radius = it))
|
||||
},
|
||||
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Number),
|
||||
textStyle = MaterialTheme.typography.bodyLarge.copy(
|
||||
color = MaterialTheme.colorScheme.onSecondary
|
||||
)
|
||||
)
|
||||
|
||||
OutlinedTextField(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
value = itemUiState.itemDetails.maxCount.toString(),
|
||||
|
@ -80,6 +80,7 @@ data class ItemDetails(
|
||||
val uid: Int = 0,
|
||||
val dateTime: LocalDateTime = LocalDateTime.MIN,
|
||||
val weight: String = "0",
|
||||
val radius: String = "0",
|
||||
val maxCount: Int = 0,
|
||||
val bikeId: Int = 0
|
||||
)
|
||||
@ -88,6 +89,7 @@ fun ItemDetails.toItem(uid: Int = 0, bikeUid: Int = 0): Item = Item(
|
||||
uid = uid,
|
||||
dateTime = dateTime,
|
||||
weight = weight.toDoubleOrNull() ?: 0.0,
|
||||
radius = radius.toDoubleOrNull() ?: 0.0,
|
||||
maxCount = maxCount,
|
||||
bikeId = bikeUid
|
||||
)
|
||||
@ -96,6 +98,7 @@ fun Item.toDetails(): ItemDetails = ItemDetails(
|
||||
uid = uid,
|
||||
dateTime = dateTime,
|
||||
weight = weight.toString(),
|
||||
radius = radius.toString(),
|
||||
maxCount = maxCount,
|
||||
bikeId = bikeId
|
||||
)
|
||||
|
@ -16,7 +16,7 @@ interface BikeDao {
|
||||
fun getAll(): PagingSource<Int, Bike>
|
||||
|
||||
@Query(
|
||||
"SELECT c.*, s.uid as item_uid, s.date_time, s.weight, s.max_count-IFNULL(SUM(os.count), 0) as available_count, c.uid as bike_id " +
|
||||
"SELECT c.*, s.uid as item_uid, s.date_time, s.weight, s.radius, s.max_count-IFNULL(SUM(os.count), 0) as available_count, c.uid as bike_id " +
|
||||
"FROM bikes AS c " +
|
||||
"LEFT JOIN items AS s ON s.bike_id = c.uid " +
|
||||
"LEFT JOIN rents_items AS os ON os.item_id = s.uid " +
|
||||
|
@ -15,7 +15,7 @@ interface RentDao {
|
||||
fun getAll(userId: Int?): PagingSource<Int, Rent>
|
||||
|
||||
@Query(
|
||||
"SELECT o.*, s.*, os.count, os.frozen_weight " +
|
||||
"SELECT o.*, s.*, os.count, os.frozen_weight, os.radius " +
|
||||
"FROM rents AS o " +
|
||||
"JOIN rents_items AS os ON os.rent_id = o.uid " +
|
||||
"JOIN items AS s ON s.uid = os.item_id " +
|
||||
|
@ -24,6 +24,7 @@ data class Item(
|
||||
@ColumnInfo(name = "date_time")
|
||||
val dateTime: LocalDateTime,
|
||||
val weight: Double,
|
||||
val radius: Double,
|
||||
@ColumnInfo(name = "max_count")
|
||||
val maxCount: Int,
|
||||
@ColumnInfo(name = "bike_id", index = true)
|
||||
@ -33,9 +34,10 @@ data class Item(
|
||||
constructor(
|
||||
dateTime: LocalDateTime,
|
||||
weight: Double,
|
||||
radius: Double,
|
||||
maxCount: Int,
|
||||
bike: Bike,
|
||||
) : this(0, dateTime, weight, maxCount, bike.uid)
|
||||
) : this(0, dateTime, weight,radius, maxCount, bike.uid)
|
||||
|
||||
companion object {
|
||||
fun getItem(index: Int = 0): Item {
|
||||
@ -43,6 +45,7 @@ data class Item(
|
||||
index,
|
||||
LocalDateTime.MIN,
|
||||
0.0,
|
||||
0.0,
|
||||
0,
|
||||
0
|
||||
)
|
||||
@ -56,6 +59,7 @@ data class Item(
|
||||
if (uid != other.uid) return false
|
||||
if (dateTime != other.dateTime) return false
|
||||
if (weight != other.weight) return false
|
||||
if (radius != other.radius) return false
|
||||
if (maxCount != other.maxCount) return false
|
||||
if (bikeId != other.bikeId) return false
|
||||
return true
|
||||
@ -65,6 +69,7 @@ data class Item(
|
||||
var result = uid
|
||||
result = 31 * result + dateTime.hashCode()
|
||||
result = 31 * result + weight.hashCode()
|
||||
result = 31 * result + radius.hashCode()
|
||||
result = 31 * result + maxCount.hashCode()
|
||||
result = 31 * result + bikeId.hashCode()
|
||||
return result
|
||||
|
@ -10,6 +10,7 @@ data class ItemFromBike(
|
||||
@ColumnInfo(name = "date_time")
|
||||
val dateTime: LocalDateTime,
|
||||
val weight: Double,
|
||||
val radius: Double,
|
||||
@ColumnInfo(name = "available_count")
|
||||
var availableCount: Int,
|
||||
@ColumnInfo(name = "bike_id")
|
||||
@ -23,6 +24,7 @@ data class ItemFromBike(
|
||||
val dateFormatter = DateTimeFormatter.ofPattern("yyyy")
|
||||
if (dateFormatter.format(dateTime) != dateFormatter.format(other.dateTime)) return false
|
||||
if (weight != other.weight) return false
|
||||
if (radius != other.radius) return false
|
||||
if (availableCount != other.availableCount) return false
|
||||
if (bikeId != other.bikeId) return false
|
||||
return true
|
||||
@ -32,6 +34,7 @@ data class ItemFromBike(
|
||||
var result = uid
|
||||
result = 31 * result + dateTime.hashCode()
|
||||
result = 31 * result + weight.hashCode()
|
||||
result = 31 * result + radius.hashCode()
|
||||
result = 31 * result + availableCount.hashCode()
|
||||
result = 31 * result + bikeId.hashCode()
|
||||
return result
|
||||
@ -42,6 +45,7 @@ fun ItemFromBike.toItem(): Item = Item (
|
||||
uid,
|
||||
dateTime,
|
||||
weight,
|
||||
radius,
|
||||
availableCount,
|
||||
bikeId
|
||||
)
|
@ -10,6 +10,7 @@ data class ItemFromCart(
|
||||
@ColumnInfo(name = "date_time")
|
||||
val dateTime: LocalDateTime,
|
||||
val weight: Double,
|
||||
val radius: Double,
|
||||
@ColumnInfo(name = "available_count")
|
||||
val availableCount: Int,
|
||||
val count: Int,
|
||||
|
@ -11,6 +11,7 @@ data class ItemFromRent(
|
||||
val dateTime: LocalDateTime,
|
||||
@ColumnInfo(name = "frozen_weight")
|
||||
val frozenWeight: Double,
|
||||
val radius: Double,
|
||||
val count: Int,
|
||||
@ColumnInfo(name = "bike_id")
|
||||
val bikeId: Int = 0,
|
||||
|
@ -15,6 +15,7 @@ data class RentItemCrossRef(
|
||||
val itemId: Int,
|
||||
@ColumnInfo(name = "frozen_weight")
|
||||
val frozenWeight: Double,
|
||||
val radius: Double,
|
||||
val count: Int
|
||||
) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
|
@ -14,7 +14,16 @@
|
||||
}
|
||||
],
|
||||
"rents": [],
|
||||
"items": [],
|
||||
"items": [
|
||||
{
|
||||
"dateTime": 2020,
|
||||
"weight": 23.6,
|
||||
"radius": 14,
|
||||
"maxCount": 5,
|
||||
"bikeId": 3,
|
||||
"id": 1
|
||||
}
|
||||
],
|
||||
"bikes": [
|
||||
{
|
||||
"name": "BMX",
|
||||
|
@ -39,6 +39,7 @@ function generateReport(items) {
|
||||
id: item.id,
|
||||
dateTime: item.dateTime,
|
||||
weight: item.weight,
|
||||
radius: item.radius,
|
||||
maxCount: item.maxCount,
|
||||
bikeId: item.bikeId
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user