Przeglądaj źródła

Disable hardcoded reports

debrand
Harry Groves 1 miesiąc temu
rodzic
commit
44907651da
3 zmienionych plików z 16 dodań i 26 usunięć
  1. +1
    -14
      src/main/java/com/ffii/fpsms/m18/M18GrnRules.kt
  2. +1
    -10
      src/main/java/com/ffii/fpsms/modules/report/service/ReportService.kt
  3. +14
    -2
      src/main/java/com/ffii/fpsms/modules/report/web/ReportController.kt

+ 1
- 14
src/main/java/com/ffii/fpsms/m18/M18GrnRules.kt Wyświetl plik

@@ -3,20 +3,7 @@ package com.ffii.fpsms.m18
/**
* M18 PO [createUid] is stored on [com.ffii.fpsms.modules.purchaseOrder.entity.PurchaseOrder.m18CreatedUId].
* For these M18 user ids, FPSMS does not post GRN to M18 (see [com.ffii.fpsms.modules.stock.service.StockInLineService]).
* Remarks are shown on PO stock-in traceability report ([com.ffii.fpsms.modules.report.service.ReportService.searchStockInTraceabilityReport]).
*/
object M18GrnRules {
private val REMARKS_FOR_M18_CREATED_UID: Map<Long, String> = mapOf(
2569L to "legato",
2676L to "xtech",
)

val SKIP_GRN_FOR_M18_CREATED_UIDS: Set<Long> = REMARKS_FOR_M18_CREATED_UID.keys

/** Display string for PDF/Excel: `2569 (legato)`, or plain id when unknown. */
fun formatM18CreatedUidForReport(uid: Long?): String {
if (uid == null) return ""
val remark = REMARKS_FOR_M18_CREATED_UID[uid]
return if (remark != null) "$uid ($remark)" else uid.toString()
}
val SKIP_GRN_FOR_M18_CREATED_UIDS: Set<Long> = setOf(2569L, 2676L)
}

+ 1
- 10
src/main/java/com/ffii/fpsms/modules/report/service/ReportService.kt Wyświetl plik

@@ -831,8 +831,7 @@ return result
MAX(ROUND(COALESCE(pol.up, 0) * COALESCE(sil.acceptedQty, 0), 2)) AS lineAmount,
MAX(COALESCE(cur.code, '')) AS currencyCode,
MAX(grn.grn_code) AS grnCode,
MAX(grn.m18_record_id) AS grnId,
MAX(po.m18CreatedUId) AS poM18CreatedUId
MAX(grn.m18_record_id) AS grnId
FROM stock_in_line sil
LEFT JOIN items it ON sil.itemId = it.id
LEFT JOIN purchase_order po ON sil.purchaseOrderId = po.id
@@ -895,14 +894,6 @@ return result
"currencyCode" to row["currencyCode"],
"grnCode" to row["grnCode"],
"grnId" to row["grnId"],
"poM18CreatorDisplay" to M18GrnRules.formatM18CreatedUidForReport(
when (val v = row["poM18CreatedUId"]) {
null -> null
is Number -> v.toLong()
is BigDecimal -> v.toLong()
else -> v.toString().toLongOrNull()
},
),
)
}
}


+ 14
- 2
src/main/java/com/ffii/fpsms/modules/report/web/ReportController.kt Wyświetl plik

@@ -14,8 +14,10 @@ import org.apache.poi.ss.util.CellRangeAddress
import org.apache.poi.ss.util.WorkbookUtil
import org.apache.poi.xssf.usermodel.XSSFCellStyle
import org.apache.poi.xssf.usermodel.XSSFWorkbook
import org.springframework.beans.factory.annotation.Value
import org.springframework.http.*
import org.springframework.web.bind.annotation.*
import org.springframework.web.server.ResponseStatusException
import java.io.ByteArrayOutputStream
import java.io.InputStream
import java.time.LocalDate
@@ -33,7 +35,13 @@ class ReportController(
private val reportService: ReportService,
private val m18BomShopSyncReportService: M18BomShopSyncReportService,
private val shopOrderReplenishmentReportService: ShopOrderReplenishmentReportService,
@Value("\${fpsms.demo-mode:false}") private val demoMode: Boolean,
) {
private fun refuseIfDemo() {
if (demoMode) {
throw ResponseStatusException(HttpStatus.FORBIDDEN, "Unavailable in demo mode")
}
}
private data class ExcelStyles(
val title: XSSFCellStyle,
val subtitle: XSSFCellStyle,
@@ -1238,18 +1246,21 @@ class ReportController(
@RequestParam(required = false) syncDateEnd: String?,
@RequestParam(required = false) finishedItemCode: String?,
@RequestParam(required = false) syncStatus: String?,
): Map<String, Any> =
m18BomShopSyncReportService.searchBomShopSyncHistoryReport(
): Map<String, Any> {
refuseIfDemo()
return m18BomShopSyncReportService.searchBomShopSyncHistoryReport(
syncDateStart = syncDateStart,
syncDateEnd = syncDateEnd,
finishedItemCode = finishedItemCode,
syncStatus = syncStatus,
)
}

@PostMapping("/bom-shop-sync-history")
fun getBomShopSyncHistoryReportPost(
@RequestBody(required = false) req: ReportItemFilterRequest?,
): Map<String, Any> {
refuseIfDemo()
val r = req ?: ReportItemFilterRequest()
return m18BomShopSyncReportService.searchBomShopSyncHistoryReport(
syncDateStart = r.syncDateStart,
@@ -1301,6 +1312,7 @@ class ReportController(
@RequestParam receiptDate: String,
@RequestParam(required = false, defaultValue = "json") format: String,
): Any {
refuseIfDemo()
val rows = reportService.searchGrnPreviewM18(receiptDate)
if (format.equals("csv", ignoreCase = true)) {
val headers = listOf(


Ładowanie…
Anuluj
Zapisz