stock module latest today vadivel J 10-02-2025
This commit is contained in:
parent
21cd2aa633
commit
228d2d0cc1
@ -72,184 +72,134 @@ class TrpProductionModel extends Model
|
|||||||
// dd($materialCodes);
|
// dd($materialCodes);
|
||||||
|
|
||||||
|
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
|
|
||||||
tpmd.date,
|
tpmd.date,
|
||||||
tpmd.openingTime,
|
tpmd.openingTime,
|
||||||
tpmd.closingTime,
|
tpmd.closingTime,
|
||||||
tpmd.totalHours,
|
tpmd.totalHours,
|
||||||
tpmd.coldStart,
|
tpmd.coldStart,
|
||||||
tpmd.breakdownHours,
|
tpmd.breakdownHours,
|
||||||
tpmd.burnerFiringHours,
|
tpmd.burnerFiringHours,
|
||||||
tpmd.sandFeedingHours,
|
tpmd.sandFeedingHours,
|
||||||
tpmd.workingPersonEngineers,
|
tpmd.workingPersonEngineers,
|
||||||
tpmd.workingPersonSupervisiors,
|
tpmd.workingPersonSupervisiors,
|
||||||
tpmd.workingPersonOperators,
|
tpmd.workingPersonOperators,
|
||||||
tpmd.rollerDrivers,
|
tpmd.rollerDrivers,
|
||||||
tpmd.natureOfMaintenance,
|
tpmd.natureOfMaintenance,
|
||||||
tpmd.location,
|
tpmd.location,
|
||||||
tpmd.description,
|
tpmd.description,
|
||||||
|
|
||||||
|
tpd.gasReceiptBg,
|
||||||
|
tpd.gasReceiptPg,
|
||||||
tpd.gasReceiptBg,
|
tpd.physicalGasConsumption,
|
||||||
tpd.gasReceiptPg,
|
tpd.trpPlusDrierGasConsumption,
|
||||||
tpd.physicalGasConsumption,
|
tpd.trpPhysicalGasPerTon,
|
||||||
tpd.trpPlusDrierGasConsumption,
|
tpd.panelGasConsumption,
|
||||||
tpd.trpPhysicalGasPerTon,
|
tpd.panelGasPerTon,
|
||||||
tpd.panelGasConsumption,
|
tpd.edRunningHours,
|
||||||
tpd.panelGasPerTon,
|
tpd.edProduction,
|
||||||
tpd.edRunningHours,
|
tpd.edUsage,
|
||||||
tpd.edProduction,
|
tpd.trpProduction,
|
||||||
tpd.edUsage,
|
tpd.trpProductionPerHour,
|
||||||
tpd.trpProduction,
|
tpd.waterReceipt,
|
||||||
tpd.trpProductionPerHour,
|
tpd.waterConsumption,
|
||||||
tpd.waterReceipt,
|
tpd.ebReading,
|
||||||
tpd.waterConsumption,
|
tpd.ebReadingPerUnitTon,
|
||||||
tpd.ebReading,
|
|
||||||
tpd.ebReadingPerUnitTon,
|
tpwd.msSeperation,
|
||||||
|
tpwd.edWaste,
|
||||||
|
tpwd.coolerBags,
|
||||||
tpwd.msSeperation,
|
tpwd.edPlus20Waste,
|
||||||
tpwd.edWaste,
|
tpwd.cycloneWaste,
|
||||||
tpwd.coolerBags,
|
|
||||||
tpwd.edPlus20Waste,
|
-- Aggregated totalGasConsumption for Coating Machine
|
||||||
tpwd.cycloneWaste,
|
IFNULL(tcmd.totalGasConsumption, 0) AS coatingGasConsumption,
|
||||||
|
|
||||||
|
-- Aggregated totalGasConsumption for Drier Machine
|
||||||
tcmd.totalGasConsumption as coatingGasConsumption,
|
IFNULL(tdmd.totalGasConsumption, 0) AS drierGasConsumption,
|
||||||
|
|
||||||
tdmd.total_gas_consumption as drierGasConsumption,
|
tsu.total_kgs AS coating,
|
||||||
|
|
||||||
|
invItems.*,
|
||||||
tsu.total_kgs as coating,
|
tigrdot.*
|
||||||
|
|
||||||
invItems.*,
|
FROM
|
||||||
|
t_trpProductionMaintenanceDetails tpmd
|
||||||
|
|
||||||
tigrdot.*
|
JOIN
|
||||||
|
t_trpProductionDetails tpd ON tpd.date = tpmd.date
|
||||||
|
JOIN
|
||||||
FROM
|
t_trpProductionWasteDetails tpwd ON tpwd.date = tpmd.date
|
||||||
t_trpProductionMaintenanceDetails tpmd
|
LEFT JOIN
|
||||||
JOIN
|
t_trp_sand_use tsu ON tsu.date = tpmd.date
|
||||||
t_trpProductionDetails tpd ON tpd.date = tpmd.date
|
|
||||||
JOIN
|
-- Aggregated Coating Machine Gas Consumption
|
||||||
t_trpProductionWasteDetails tpwd ON tpwd.date = tpmd.date
|
LEFT JOIN (
|
||||||
LEFT JOIN
|
SELECT date, SUM(totalGasConsumption) AS totalGasConsumption
|
||||||
t_coatingMachineDetails tcmd ON tcmd.date = tpmd.date
|
FROM t_coatingMachineDetails
|
||||||
LEFT JOIN
|
GROUP BY date
|
||||||
t_drierMachineDetails tdmd ON tdmd.date = tpmd.date
|
) tcmd ON tcmd.date = tpmd.date
|
||||||
LEFT JOIN
|
|
||||||
t_trp_sand_use tsu ON tsu.date = tpmd.date
|
-- Aggregated Drier Machine Gas Consumption
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT date, SUM(total_gas_consumption) AS totalGasConsumption
|
||||||
|
FROM t_drierMachineDetails
|
||||||
LEFT JOIN
|
GROUP BY date
|
||||||
(
|
) tdmd ON tdmd.date = tpmd.date
|
||||||
SELECT
|
|
||||||
invItems.item_date_added,
|
-- Aggregating Core Sand Reclaimed by Client
|
||||||
SUM(CASE WHEN clients.client_name = 'ASHOK LEYLAND LIMITED (FOUNDRY DIVISION-SRIPERUMBUDUR)' THEN invItems.item_quantity ELSE 0 END) AS
|
LEFT JOIN (
|
||||||
`ALs_crs`,
|
SELECT
|
||||||
SUM(CASE WHEN clients.client_name = 'NEMAK ALUMINIUM CASTING INDIA PVT LTD' THEN invItems.item_quantity ELSE 0 END) AS
|
invItems.item_date_added,
|
||||||
`Nemak_crs`,
|
SUM(CASE WHEN clients.client_name = 'ASHOK LEYLAND LIMITED (FOUNDRY DIVISION-SRIPERUMBUDUR)' THEN invItems.item_quantity ELSE 0 END) AS `ALs_crs`,
|
||||||
SUM(CASE WHEN clients.client_name = 'MADRAS ENGINEERING INDUSTRIES PRIVATE LIMITED' THEN invItems.item_quantity ELSE 0 END) AS
|
SUM(CASE WHEN clients.client_name = 'NEMAK ALUMINIUM CASTING INDIA PVT LTD' THEN invItems.item_quantity ELSE 0 END) AS `Nemak_crs`,
|
||||||
`ME_crs`,
|
SUM(CASE WHEN clients.client_name = 'MADRAS ENGINEERING INDUSTRIES PRIVATE LIMITED' THEN invItems.item_quantity ELSE 0 END) AS `ME_crs`,
|
||||||
SUM(CASE WHEN clients.client_name = 'BRAKES INDIA PRIVATE LIMITED' THEN invItems.item_quantity ELSE 0 END) AS
|
SUM(CASE WHEN clients.client_name = 'BRAKES INDIA PRIVATE LIMITED' THEN invItems.item_quantity ELSE 0 END) AS `BI_crs`,
|
||||||
`BI_crs`,
|
SUM(CASE WHEN clients.client_name = 'KARMEN INTERNATIONAL PVT LTD' THEN invItems.item_quantity ELSE 0 END) AS `Karmen_crs`
|
||||||
SUM(CASE WHEN clients.client_name = 'KARMEN INTERNATIONAL PVT LTD' THEN invItems.item_quantity ELSE 0 END) AS
|
FROM
|
||||||
`Karmen_crs`
|
ip_invoice_items invItems
|
||||||
|
LEFT JOIN
|
||||||
|
ip_invoices inv ON inv.invoice_id = invItems.invoice_id
|
||||||
FROM
|
LEFT JOIN
|
||||||
ip_invoice_items invItems
|
ip_clients clients ON clients.client_id = inv.client_id
|
||||||
LEFT JOIN
|
WHERE
|
||||||
ip_invoices inv ON inv.invoice_id = invItems.invoice_id
|
invItems.item_name = 'Core Sand Reclaimed'
|
||||||
LEFT JOIN
|
AND invItems.item_date_added >= '$startDate'
|
||||||
ip_clients clients ON clients.client_id = inv.client_id
|
AND invItems.item_date_added <= '$endDate'
|
||||||
WHERE
|
GROUP BY
|
||||||
invItems.item_name = 'Core Sand Reclaimed'
|
invItems.item_date_added
|
||||||
|
) invItems ON invItems.item_date_added = tpmd.date
|
||||||
AND
|
|
||||||
invItems.item_date_added >= '$startDate'
|
-- Aggregating Waste Core Sand Suppliers
|
||||||
|
LEFT JOIN (
|
||||||
AND
|
SELECT
|
||||||
invItems.item_date_added <= '$endDate'
|
tigrd.CreatedDate,
|
||||||
|
SUM(CASE WHEN ts.SupplierName = 'Ashok leyland limited foundry divn-SPU' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS `ALs_wcs`,
|
||||||
GROUP BY
|
SUM(CASE WHEN ts.SupplierName = 'Ashok leyland limited foundry divn-ENU' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS `ALe_wcs`,
|
||||||
invItems.item_date_added
|
SUM(CASE WHEN ts.SupplierName = 'MADRAS ENGINEERING INDUSTRIES PRIVATE LIMITED' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS `ME_wcs`,
|
||||||
|
SUM(CASE WHEN ts.SupplierName = 'SIDDHARTH INDUSTRIES' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS `SI_wcs`,
|
||||||
|
SUM(CASE WHEN ts.SupplierName = 'Caparo Engineering India Limited' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS `caparo_wcs`,
|
||||||
) invItems
|
SUM(CASE WHEN ts.SupplierName = 'NEMAK ALUMINIUM CASTING INDIA PVT LTD' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS `Nemak_wcs`,
|
||||||
ON invItems.item_date_added = tpmd.date
|
SUM(CASE WHEN ts.SupplierName = 'DR Axion India Private Limited' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS `DR_wcs`
|
||||||
|
FROM t_igr_details tigrd
|
||||||
|
LEFT JOIN t_igr_master tigm ON tigm.IGRNo = tigrd.IGRNo
|
||||||
|
LEFT JOIN t_purchaseorder_master tpom ON tpom.PONO = tigm.PONO
|
||||||
LEFT JOIN
|
LEFT JOIN t_supplierdetailsn ts ON tpom.SupplierID = ts.SupplierID
|
||||||
(
|
WHERE
|
||||||
|
tigrd.MaterialCode IN ($materialCodesString)
|
||||||
Select
|
AND tigrd.CreatedDate >= '$startDate'
|
||||||
|
AND tigrd.CreatedDate <= '$endDate'
|
||||||
tigrd.CreatedDate ,
|
GROUP BY Date(tigrd.CreatedDate)
|
||||||
|
) tigrdot ON DATE(tigrdot.CreatedDate) = tpmd.date
|
||||||
SUM(CASE WHEN ts.SupplierName = 'Ashok leyland limited foundry divn-SPU' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS
|
|
||||||
`ALs_wcs`,
|
WHERE
|
||||||
SUM(CASE WHEN ts.SupplierName = 'Ashok leyland limited foundry divn-ENU' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS
|
tpmd.date >= ?
|
||||||
`ALe_wcs`,
|
AND tpmd.date <= ?
|
||||||
SUM(CASE WHEN ts.SupplierName = 'MADRAS ENGINEERING INDUSTRIES PRIVATE LIMITED' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS
|
|
||||||
`ME_wcs`,
|
ORDER BY
|
||||||
SUM(CASE WHEN ts.SupplierName = 'SIDDHARTH INDUSTRIES' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS
|
tpmd.date ASC";
|
||||||
`SI_wcs`,
|
|
||||||
SUM(CASE WHEN ts.SupplierName = 'Caparo Engineering India Limited' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS
|
|
||||||
`caparo_wcs`,
|
|
||||||
SUM(CASE WHEN ts.SupplierName = 'NEMAK ALUMINIUM CASTING INDIA PVT LTD' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS
|
|
||||||
`Nemak_wcs`,
|
|
||||||
SUM(CASE WHEN ts.SupplierName = 'DR Axion India Private Limited' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS
|
|
||||||
`DR_wcs`
|
|
||||||
|
|
||||||
from t_igr_details tigrd
|
|
||||||
|
|
||||||
-- All joins to get supplier name thats it
|
|
||||||
LEFT JOIN
|
|
||||||
t_igr_master tigm
|
|
||||||
ON tigm.IGRNo = tigrd.IGRNo
|
|
||||||
|
|
||||||
LEFT JOIN
|
|
||||||
t_purchaseorder_master tpom
|
|
||||||
ON tpom.PONO = tigm.PONO
|
|
||||||
|
|
||||||
LEFT JOIN
|
|
||||||
t_supplierdetailsn ts
|
|
||||||
ON tpom.SupplierID = ts.SupplierID
|
|
||||||
|
|
||||||
-- getting waste core sands using three distinct material codes
|
|
||||||
Where
|
|
||||||
tigrd.MaterialCode IN ($materialCodesString)
|
|
||||||
|
|
||||||
AND
|
|
||||||
tigrd.CreatedDate >= '$startDate'
|
|
||||||
|
|
||||||
AND
|
|
||||||
tigrd.CreatedDate <= '$endDate'
|
|
||||||
|
|
||||||
-- grouping supplier who provides waste core on a particular date with 1 or more IGRS
|
|
||||||
Group By Date(tigrd.CreatedDate)
|
|
||||||
|
|
||||||
) tigrdot
|
|
||||||
|
|
||||||
ON DATE(tigrdot.CreatedDate) = tpmd.date
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WHERE
|
|
||||||
tpmd.date >= ?
|
|
||||||
AND
|
|
||||||
tpmd.date <= ?
|
|
||||||
|
|
||||||
|
|
||||||
ORDER BY
|
|
||||||
tpmd.date ASC";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -549,7 +549,17 @@ foreach ($period as $day) {
|
|||||||
$summary["machineId_$machineId"]['filling_diesel'] += is_numeric($dieselStock['filling_diesel']) ? $dieselStock['filling_diesel'] : 0 ;
|
$summary["machineId_$machineId"]['filling_diesel'] += is_numeric($dieselStock['filling_diesel']) ? $dieselStock['filling_diesel'] : 0 ;
|
||||||
$summary["machineId_$machineId"]['consumption'] += is_numeric($dieselStock['consumption']) ? $dieselStock['consumption'] : 0 ;
|
$summary["machineId_$machineId"]['consumption'] += is_numeric($dieselStock['consumption']) ? $dieselStock['consumption'] : 0 ;
|
||||||
$summary["machineId_$machineId"]['running_hours'] += is_numeric($dieselStock['running_hours']) ? $dieselStock['running_hours'] : 0 ;
|
$summary["machineId_$machineId"]['running_hours'] += is_numeric($dieselStock['running_hours']) ? $dieselStock['running_hours'] : 0 ;
|
||||||
$summary["machineId_$machineId"]['mileage'] += is_numeric($dieselStock['mileage']) ? $dieselStock['mileage'] : 0 ;
|
|
||||||
|
if($summary["machineId_$machineId"]['running_hours'] > 0){
|
||||||
|
$dieselMileage = round(
|
||||||
|
$summary["machineId_$machineId"]['consumption'] / $summary["machineId_$machineId"]['running_hours'],
|
||||||
|
2
|
||||||
|
);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$dieselMileage = 0 ;
|
||||||
|
}
|
||||||
|
$summary["machineId_$machineId"]['mileage'] = is_numeric( $dieselMileage) ? $dieselMileage : 0 ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user