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);
|
||||
|
||||
|
||||
$sql = "SELECT
|
||||
$sql = "SELECT
|
||||
|
||||
tpmd.date,
|
||||
tpmd.openingTime,
|
||||
tpmd.closingTime,
|
||||
tpmd.totalHours,
|
||||
tpmd.coldStart,
|
||||
tpmd.breakdownHours,
|
||||
tpmd.burnerFiringHours,
|
||||
tpmd.sandFeedingHours,
|
||||
tpmd.workingPersonEngineers,
|
||||
tpmd.workingPersonSupervisiors,
|
||||
tpmd.workingPersonOperators,
|
||||
tpmd.rollerDrivers,
|
||||
tpmd.natureOfMaintenance,
|
||||
tpmd.location,
|
||||
tpmd.description,
|
||||
|
||||
|
||||
|
||||
tpd.gasReceiptBg,
|
||||
tpd.gasReceiptPg,
|
||||
tpd.physicalGasConsumption,
|
||||
tpd.trpPlusDrierGasConsumption,
|
||||
tpd.trpPhysicalGasPerTon,
|
||||
tpd.panelGasConsumption,
|
||||
tpd.panelGasPerTon,
|
||||
tpd.edRunningHours,
|
||||
tpd.edProduction,
|
||||
tpd.edUsage,
|
||||
tpd.trpProduction,
|
||||
tpd.trpProductionPerHour,
|
||||
tpd.waterReceipt,
|
||||
tpd.waterConsumption,
|
||||
tpd.ebReading,
|
||||
tpd.ebReadingPerUnitTon,
|
||||
|
||||
|
||||
tpwd.msSeperation,
|
||||
tpwd.edWaste,
|
||||
tpwd.coolerBags,
|
||||
tpwd.edPlus20Waste,
|
||||
tpwd.cycloneWaste,
|
||||
|
||||
|
||||
tcmd.totalGasConsumption as coatingGasConsumption,
|
||||
|
||||
tdmd.total_gas_consumption as drierGasConsumption,
|
||||
|
||||
|
||||
tsu.total_kgs as coating,
|
||||
|
||||
invItems.*,
|
||||
|
||||
|
||||
tigrdot.*
|
||||
|
||||
|
||||
FROM
|
||||
t_trpProductionMaintenanceDetails tpmd
|
||||
JOIN
|
||||
t_trpProductionDetails tpd ON tpd.date = tpmd.date
|
||||
JOIN
|
||||
t_trpProductionWasteDetails tpwd ON tpwd.date = tpmd.date
|
||||
LEFT JOIN
|
||||
t_coatingMachineDetails tcmd ON tcmd.date = tpmd.date
|
||||
LEFT JOIN
|
||||
t_drierMachineDetails tdmd ON tdmd.date = tpmd.date
|
||||
LEFT JOIN
|
||||
t_trp_sand_use tsu ON tsu.date = tpmd.date
|
||||
|
||||
|
||||
|
||||
LEFT JOIN
|
||||
(
|
||||
SELECT
|
||||
invItems.item_date_added,
|
||||
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 = 'NEMAK ALUMINIUM CASTING INDIA PVT LTD' THEN invItems.item_quantity ELSE 0 END) AS
|
||||
`Nemak_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
|
||||
`BI_crs`,
|
||||
SUM(CASE WHEN clients.client_name = 'KARMEN INTERNATIONAL PVT LTD' THEN invItems.item_quantity ELSE 0 END) AS
|
||||
`Karmen_crs`
|
||||
|
||||
|
||||
FROM
|
||||
ip_invoice_items invItems
|
||||
LEFT JOIN
|
||||
ip_invoices inv ON inv.invoice_id = invItems.invoice_id
|
||||
LEFT JOIN
|
||||
ip_clients clients ON clients.client_id = inv.client_id
|
||||
WHERE
|
||||
invItems.item_name = 'Core Sand Reclaimed'
|
||||
|
||||
AND
|
||||
invItems.item_date_added >= '$startDate'
|
||||
|
||||
AND
|
||||
invItems.item_date_added <= '$endDate'
|
||||
|
||||
GROUP BY
|
||||
invItems.item_date_added
|
||||
|
||||
|
||||
) invItems
|
||||
ON invItems.item_date_added = tpmd.date
|
||||
|
||||
|
||||
|
||||
LEFT JOIN
|
||||
(
|
||||
|
||||
Select
|
||||
|
||||
tigrd.CreatedDate ,
|
||||
|
||||
SUM(CASE WHEN ts.SupplierName = 'Ashok leyland limited foundry divn-SPU' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS
|
||||
`ALs_wcs`,
|
||||
SUM(CASE WHEN ts.SupplierName = 'Ashok leyland limited foundry divn-ENU' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS
|
||||
`ALe_wcs`,
|
||||
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`,
|
||||
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";
|
||||
tpmd.date,
|
||||
tpmd.openingTime,
|
||||
tpmd.closingTime,
|
||||
tpmd.totalHours,
|
||||
tpmd.coldStart,
|
||||
tpmd.breakdownHours,
|
||||
tpmd.burnerFiringHours,
|
||||
tpmd.sandFeedingHours,
|
||||
tpmd.workingPersonEngineers,
|
||||
tpmd.workingPersonSupervisiors,
|
||||
tpmd.workingPersonOperators,
|
||||
tpmd.rollerDrivers,
|
||||
tpmd.natureOfMaintenance,
|
||||
tpmd.location,
|
||||
tpmd.description,
|
||||
|
||||
tpd.gasReceiptBg,
|
||||
tpd.gasReceiptPg,
|
||||
tpd.physicalGasConsumption,
|
||||
tpd.trpPlusDrierGasConsumption,
|
||||
tpd.trpPhysicalGasPerTon,
|
||||
tpd.panelGasConsumption,
|
||||
tpd.panelGasPerTon,
|
||||
tpd.edRunningHours,
|
||||
tpd.edProduction,
|
||||
tpd.edUsage,
|
||||
tpd.trpProduction,
|
||||
tpd.trpProductionPerHour,
|
||||
tpd.waterReceipt,
|
||||
tpd.waterConsumption,
|
||||
tpd.ebReading,
|
||||
tpd.ebReadingPerUnitTon,
|
||||
|
||||
tpwd.msSeperation,
|
||||
tpwd.edWaste,
|
||||
tpwd.coolerBags,
|
||||
tpwd.edPlus20Waste,
|
||||
tpwd.cycloneWaste,
|
||||
|
||||
-- Aggregated totalGasConsumption for Coating Machine
|
||||
IFNULL(tcmd.totalGasConsumption, 0) AS coatingGasConsumption,
|
||||
|
||||
-- Aggregated totalGasConsumption for Drier Machine
|
||||
IFNULL(tdmd.totalGasConsumption, 0) AS drierGasConsumption,
|
||||
|
||||
tsu.total_kgs AS coating,
|
||||
|
||||
invItems.*,
|
||||
tigrdot.*
|
||||
|
||||
FROM
|
||||
t_trpProductionMaintenanceDetails tpmd
|
||||
|
||||
JOIN
|
||||
t_trpProductionDetails tpd ON tpd.date = tpmd.date
|
||||
JOIN
|
||||
t_trpProductionWasteDetails tpwd ON tpwd.date = tpmd.date
|
||||
LEFT JOIN
|
||||
t_trp_sand_use tsu ON tsu.date = tpmd.date
|
||||
|
||||
-- Aggregated Coating Machine Gas Consumption
|
||||
LEFT JOIN (
|
||||
SELECT date, SUM(totalGasConsumption) AS totalGasConsumption
|
||||
FROM t_coatingMachineDetails
|
||||
GROUP BY date
|
||||
) tcmd ON tcmd.date = tpmd.date
|
||||
|
||||
-- Aggregated Drier Machine Gas Consumption
|
||||
LEFT JOIN (
|
||||
SELECT date, SUM(total_gas_consumption) AS totalGasConsumption
|
||||
FROM t_drierMachineDetails
|
||||
GROUP BY date
|
||||
) tdmd ON tdmd.date = tpmd.date
|
||||
|
||||
-- Aggregating Core Sand Reclaimed by Client
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
invItems.item_date_added,
|
||||
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 = 'NEMAK ALUMINIUM CASTING INDIA PVT LTD' THEN invItems.item_quantity ELSE 0 END) AS `Nemak_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 `BI_crs`,
|
||||
SUM(CASE WHEN clients.client_name = 'KARMEN INTERNATIONAL PVT LTD' THEN invItems.item_quantity ELSE 0 END) AS `Karmen_crs`
|
||||
FROM
|
||||
ip_invoice_items invItems
|
||||
LEFT JOIN
|
||||
ip_invoices inv ON inv.invoice_id = invItems.invoice_id
|
||||
LEFT JOIN
|
||||
ip_clients clients ON clients.client_id = inv.client_id
|
||||
WHERE
|
||||
invItems.item_name = 'Core Sand Reclaimed'
|
||||
AND invItems.item_date_added >= '$startDate'
|
||||
AND invItems.item_date_added <= '$endDate'
|
||||
GROUP BY
|
||||
invItems.item_date_added
|
||||
) invItems ON invItems.item_date_added = tpmd.date
|
||||
|
||||
-- Aggregating Waste Core Sand Suppliers
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
tigrd.CreatedDate,
|
||||
SUM(CASE WHEN ts.SupplierName = 'Ashok leyland limited foundry divn-SPU' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS `ALs_wcs`,
|
||||
SUM(CASE WHEN ts.SupplierName = 'Ashok leyland limited foundry divn-ENU' THEN tigrd.QuantityAsPerInvoice ELSE 0 END) AS `ALe_wcs`,
|
||||
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`,
|
||||
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
|
||||
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
|
||||
WHERE
|
||||
tigrd.MaterialCode IN ($materialCodesString)
|
||||
AND tigrd.CreatedDate >= '$startDate'
|
||||
AND tigrd.CreatedDate <= '$endDate'
|
||||
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"]['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"]['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