Просмотр исходного кода

updare stockledgar report

master
CANCERYS\kw093 1 неделю назад
Родитель
Сommit
86499fb088
3 измененных файлов: 58 добавлений и 21 удалений
  1. +48
    -11
      src/main/java/com/ffii/fpsms/modules/report/service/StockLedgerReportService.kt
  2. +2
    -2
      src/main/java/com/ffii/fpsms/modules/stock/service/StockTakeRecordService.kt
  3. +8
    -8
      src/main/resources/jasper/StockLedgarReport.jrxml

+ 48
- 11
src/main/java/com/ffii/fpsms/modules/report/service/StockLedgerReportService.kt Просмотреть файл

@@ -83,7 +83,12 @@ WITH base AS (
sl.id AS slId, sl.id AS slId,
DATE(sl.date) AS trnDateRaw, DATE(sl.date) AS trnDateRaw,
DATE_FORMAT(sl.date, '%Y-%m-%d') AS trnDate, DATE_FORMAT(sl.date, '%Y-%m-%d') AS trnDate,
sl.type AS trnRefNo,
CASE
WHEN UPPER(TRIM(COALESCE(sl.type, ''))) = 'TKE' THEN 'TKE'
WHEN UPPER(TRIM(COALESCE(sl.type, ''))) = 'ADJ'
AND (so.stockTakeId IS NOT NULL OR so.type = 'stockTake' OR si.stockTakeId IS NOT NULL) THEN 'TKE'
ELSE COALESCE(sl.type, '')
END AS trnRefNoRaw,


sl.itemId AS itemId, sl.itemId AS itemId,
sl.itemCode AS itemCode, sl.itemCode AS itemCode,
@@ -101,8 +106,8 @@ WITH base AS (
COALESCE(DATE_FORMAT(lot.expiryDate, '%Y-%m-%d'), '') AS expiryDate, COALESCE(DATE_FORMAT(lot.expiryDate, '%Y-%m-%d'), '') AS expiryDate,
lot.storeLocation AS storeLocation, lot.storeLocation AS storeLocation,


'' AS orderRefNo,
'' AS jobOrderNo,
COALESCE(TRIM(do.code), TRIM(jo_po.code), TRIM(jo.code), TRIM(po.code), '') AS orderRefNo,
COALESCE(TRIM(jo.code), '') AS jobOrderNo,


'' AS openingBalance, '' AS openingBalance,
'' AS cumStockIn, '' AS cumStockIn,
@@ -168,7 +173,30 @@ WITH base AS (
LEFT JOIN warehouse wh_out LEFT JOIN warehouse wh_out
ON ill_out.warehouseId = wh_out.id ON ill_out.warehouseId = wh_out.id
AND wh_out.deleted = 0 AND wh_out.deleted = 0

LEFT JOIN stock_out so
ON sol.stockOutId = so.id
AND so.deleted = 0
LEFT JOIN pick_order_line pol
ON sol.pickOrderLineId = pol.id
AND pol.deleted = 0
LEFT JOIN pick_order po_out
ON pol.poId = po_out.id
AND po_out.deleted = 0
LEFT JOIN job_order jo_po
ON po_out.joId = jo_po.id
AND jo_po.deleted = 0
LEFT JOIN delivery_order do
ON po_out.doId = do.id
AND do.deleted = 0
LEFT JOIN stock_in si
ON sil.stockInId = si.id
AND si.deleted = 0
LEFT JOIN job_order jo
ON sil.jobOrderId = jo.id
AND jo.deleted = 0
LEFT JOIN purchase_order po
ON sil.purchaseOrderId = po.id
AND po.deleted = 0
WHERE WHERE
sl.deleted = 0 sl.deleted = 0
AND sl.itemCode IS NOT NULL AND sl.itemCode IS NOT NULL
@@ -203,8 +231,17 @@ SELECT
unitOfMeasure, unitOfMeasure,
lotNo, lotNo,
expiryDate, expiryDate,
trnDate,
trnRefNo,
trnDate,
CASE trnRefNoRaw
WHEN 'OPEN' THEN '開倉'
WHEN 'NOR' THEN '出入倉'
WHEN 'TRF' THEN '轉倉'
WHEN 'ADJ' THEN '調整'
WHEN 'MISS' THEN '遺失'
WHEN 'BAD' THEN '不良品'
WHEN 'TKE' THEN '盤點'
ELSE trnRefNoRaw
END AS trnRefNo,
storeLocation, storeLocation,
orderRefNo, orderRefNo,
jobOrderNo, jobOrderNo,
@@ -238,15 +275,15 @@ SELECT
) AS CHAR) AS cumOpeningBal, ) AS CHAR) AS cumOpeningBal,


-- footer totals(同樣輸出 String) -- footer totals(同樣輸出 String)
CAST(CAST(openingBeforeStart AS DECIMAL(20,0)) AS CHAR) AS totalCumOpeningBal,
CAST(CAST(SUM(inQty) OVER (PARTITION BY itemCode) AS DECIMAL(20,0)) AS CHAR) AS totalStockIn,
CAST(CAST(SUM(outQty) OVER (PARTITION BY itemCode) AS DECIMAL(20,0)) AS CHAR) AS totalStockOut,
CAST(CAST(
CAST(openingBeforeStart AS DECIMAL(20,0)) AS totalCumOpeningBal,
CAST(SUM(inQty) OVER (PARTITION BY itemCode) AS DECIMAL(20,0)) AS totalStockIn,
CAST(SUM(outQty) OVER (PARTITION BY itemCode) AS DECIMAL(20,0)) AS totalStockOut,
CAST(
(openingBeforeStart (openingBeforeStart
+ SUM(inQty) OVER (PARTITION BY itemCode) + SUM(inQty) OVER (PARTITION BY itemCode)
- SUM(outQty) OVER (PARTITION BY itemCode) - SUM(outQty) OVER (PARTITION BY itemCode)
) AS DECIMAL(20,0) ) AS DECIMAL(20,0)
) AS CHAR) AS totalCumBalance
) AS totalCumBalance


FROM period FROM period
ORDER BY ORDER BY


+ 2
- 2
src/main/java/com/ffii/fpsms/modules/stock/service/StockTakeRecordService.kt Просмотреть файл

@@ -931,7 +931,7 @@ class StockTakeRecordService(
this.outQty = absVariance.toDouble() this.outQty = absVariance.toDouble()
this.stockOutLine = stockOutLine this.stockOutLine = stockOutLine
this.balance = newBalance this.balance = newBalance
this.type = "Adj"
this.type = "TKE"
this.date = LocalDate.now() this.date = LocalDate.now()
} }
stockLedgerRepository.save(stockLedger) stockLedgerRepository.save(stockLedger)
@@ -974,7 +974,7 @@ class StockTakeRecordService(
this.expiryDate = inventoryLot.expiryDate this.expiryDate = inventoryLot.expiryDate
this.lotNo = inventoryLot.lotNo this.lotNo = inventoryLot.lotNo
this.status = "completed" this.status = "completed"
this.type = "ADJ"
this.type = "TKE"
// 注意:此时不设置 inventoryLot 和 inventoryLotLine,因为还没有创建 // 注意:此时不设置 inventoryLot 和 inventoryLotLine,因为还没有创建
} }
stockInLineRepository.save(stockInLine) stockInLineRepository.save(stockInLine)


+ 8
- 8
src/main/resources/jasper/StockLedgarReport.jrxml Просмотреть файл

@@ -57,10 +57,10 @@
<field name="cumStockIn" class="java.lang.String"/> <field name="cumStockIn" class="java.lang.String"/>
<field name="cumStockOut" class="java.lang.String"/> <field name="cumStockOut" class="java.lang.String"/>
<field name="currentBalance" class="java.lang.String"/> <field name="currentBalance" class="java.lang.String"/>
<field name="totalStockIn" class="java.lang.String"/>
<field name="totalCumOpeningBal" class="java.lang.String"/>
<field name="totalStockOut" class="java.lang.String"/>
<field name="totalCumBalance" class="java.lang.String"/>
<field name="totalStockIn" class="java.math.BigDecimal"/>
<field name="totalCumOpeningBal" class="java.math.BigDecimal"/>
<field name="totalStockOut" class="java.math.BigDecimal"/>
<field name="totalCumBalance" class="java.math.BigDecimal"/>
<field name="lastOutDate" class="java.lang.String"/> <field name="lastOutDate" class="java.lang.String"/>
<field name="lastInDate" class="java.lang.String"/> <field name="lastInDate" class="java.lang.String"/>
<field name="reOrderLevel" class="java.lang.String"/> <field name="reOrderLevel" class="java.lang.String"/>
@@ -100,7 +100,7 @@
</textElement> </textElement>
<text><![CDATA[貨品總量:]]></text> <text><![CDATA[貨品總量:]]></text>
</staticText> </staticText>
<textField textAdjust="StretchHeight">
<textField textAdjust="StretchHeight" pattern="#,##0">
<reportElement x="359" y="0" width="57" height="18" uuid="44b1dc52-ca89-43b5-9828-31db7207ad22"> <reportElement x="359" y="0" width="57" height="18" uuid="44b1dc52-ca89-43b5-9828-31db7207ad22">
<property name="com.jaspersoft.studio.unit.width" value="px"/> <property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement> </reportElement>
@@ -109,7 +109,7 @@
</textElement> </textElement>
<textFieldExpression><![CDATA[$F{totalCumOpeningBal}]]></textFieldExpression> <textFieldExpression><![CDATA[$F{totalCumOpeningBal}]]></textFieldExpression>
</textField> </textField>
<textField>
<textField pattern="#,##0">
<reportElement x="416" y="0" width="50" height="18" uuid="6c141d7d-766e-49bf-b987-e790312573a5"> <reportElement x="416" y="0" width="50" height="18" uuid="6c141d7d-766e-49bf-b987-e790312573a5">
<property name="com.jaspersoft.studio.unit.width" value="px"/> <property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement> </reportElement>
@@ -118,7 +118,7 @@
</textElement> </textElement>
<textFieldExpression><![CDATA[$F{totalStockIn}]]></textFieldExpression> <textFieldExpression><![CDATA[$F{totalStockIn}]]></textFieldExpression>
</textField> </textField>
<textField textAdjust="StretchHeight">
<textField textAdjust="StretchHeight" pattern="#,##0">
<reportElement x="466" y="0" width="50" height="18" uuid="f6be72ca-650f-4c37-a149-26d5502be17a"> <reportElement x="466" y="0" width="50" height="18" uuid="f6be72ca-650f-4c37-a149-26d5502be17a">
<property name="com.jaspersoft.studio.unit.width" value="px"/> <property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement> </reportElement>
@@ -127,7 +127,7 @@
</textElement> </textElement>
<textFieldExpression><![CDATA[$F{totalStockOut}]]></textFieldExpression> <textFieldExpression><![CDATA[$F{totalStockOut}]]></textFieldExpression>
</textField> </textField>
<textField>
<textField pattern="#,##0">
<reportElement x="524" y="0" width="66" height="18" uuid="636bf782-3020-4b49-837e-53ede91d1443"> <reportElement x="524" y="0" width="66" height="18" uuid="636bf782-3020-4b49-837e-53ede91d1443">
<property name="com.jaspersoft.studio.unit.width" value="px"/> <property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement> </reportElement>


Загрузка…
Отмена
Сохранить