Parcourir la source

update overcons

tags/Baseline_30082024_BACKEND_UAT
MSI\derek il y a 1 an
Parent
révision
2b3612714a
2 fichiers modifiés avec 25 ajouts et 41 suppressions
  1. +25
    -40
      src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt
  2. +0
    -1
      src/main/java/com/ffii/tsms/modules/report/web/ReportController.kt

+ 25
- 40
src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt Voir le fichier

@@ -2117,46 +2117,31 @@ open class ReportService(

open fun getProjectResourceOverconsumptionReport(args: Map<String, Any>): List<Map<String, Any>> {
val sql = StringBuilder(
"SELECT"
+ " p.code, "
+ " p.name, "
+ " tm.code as team, "
+ " concat(c.code, ' - ',c.name) as client, "
+ " COALESCE(concat(ss.code, ' - ', ss.name), 'N/A') as subsidiary, "
+ " (p.expectedTotalFee - ifnull(p.subContractFee, 0)) * 0.8 as plannedBudget, "
+ " sum(t.consumedBudget) as actualConsumedBudget, "
+ " COALESCE(p.totalManhour, 0) as plannedManhour, "
+ " sum(t.normalConsumed + COALESCE(t.otConsumed, 0)) as actualConsumedManhour, "
+ " sum(t.consumedBudget) / ((p.expectedTotalFee - ifnull(p.subContractFee, 0)) * 0.8) as budgetConsumptionRate, "
+ " sum(t.normalConsumed + COALESCE(t.otConsumed, 0)) / COALESCE(p.totalManhour, 0) as manhourConsumptionRate, "
+ " case "
+ " when sum(t.consumedBudget) / ((p.expectedTotalFee - ifnull(p.subContractFee, 0)) * 0.8) >= 1 "
+ " or (sum(t.normalConsumed + COALESCE(t.otConsumed, 0)) / COALESCE(p.totalManhour, 0)) >= 1 "
+ " then 'Overconsumption' "
+ " when sum(t.consumedBudget) / ((p.expectedTotalFee - ifnull(p.subContractFee, 0)) * 0.8) >= :lowerLimit and sum(t.consumedBudget) / ((p.expectedTotalFee - ifnull(p.subContractFee, 0)) * 0.8) <= 1 "
+ " or (sum(t.normalConsumed + COALESCE(t.otConsumed, 0)) / COALESCE(p.totalManhour, 0)) >= :lowerLimit and (sum(t.normalConsumed + COALESCE(t.otConsumed, 0)) / COALESCE(p.totalManhour, 0)) <= 1 "
+ " then 'Potential Overconsumption' "
+ " else 'Within Budget' "
+ " END as status "
+ " from "
+ " (SELECT t.*, (t.normalConsumed + COALESCE(t.otConsumed, 0)) * sal.hourlyRate as consumedBudget "
+ " FROM "
+ " ( "
+ " SELECT t.id AS tid, max(se.date) AS max_date "
+ " FROM timesheet t "
+ " INNER JOIN salary_effective se ON se.staffId = t.staffId AND se.date <= t.recordDate "
+ " GROUP BY t.id "
+ " ) max_se "
+ " LEFT JOIN timesheet t ON t.id = max_se.tid "
+ " LEFT JOIN staff s on s.id = t.staffId "
+ " inner join salary_effective se on se.date = max_se.max_date "
+ " left join salary sal on se.salaryId = sal.salaryPoint) t "
+ " left join project p on p.id = t.projectId "
+ " left join team tm on p.teamLead = tm.teamLead "
+ " left join customer c on c.id = p.customerId "
+ " LEFT JOIN subsidiary ss on p.customerSubsidiaryId = ss.id "
+ " WHERE p.deleted = false "
+ " and p.status = 'On-going' "
" SELECT "
+ " p.code, p.name, tm.code as team, concat(c.code, ' -',c.name) as client, COALESCE(concat(ss.code, ' -', ss.name), 'N/A') as subsidiary "
+ " , (p.expectedTotalFee - ifnull(p.subContractFee, 0)) * 0.8 as plannedBudget, sum(t.consumedBudget) as actualConsumedBudget "
+ " , COALESCE(p.totalManhour, 0) as plannedManhour, sum(t.normalConsumed + COALESCE(t.otConsumed, 0)) as actualConsumedManhour "
+ " , sum(t.consumedBudget) / ((p.expectedTotalFee - ifnull(p.subContractFee, 0)) * 0.8) as budgetConsumptionRate "
+ " , sum(t.normalConsumed + COALESCE(t.otConsumed, 0)) / COALESCE(p.totalManhour, 0) as manhourConsumptionRate "
+ " , case when sum(t.consumedBudget) / ((p.expectedTotalFee - ifnull(p.subContractFee, 0)) * 0.8) >= 1 "
+ " or (sum(t.normalConsumed + COALESCE(t.otConsumed,0)) / COALESCE(p.totalManhour,0)) >= 1 "
+ " then'Overconsumption' when sum(t.consumedBudget)/ ((p.expectedTotalFee - ifnull(p.subContractFee,0)) * 0.8) >= :lowerLimit "
+ " and sum(t.consumedBudget)/ ((p.expectedTotalFee - ifnull(p.subContractFee,0)) * 0.8) <= 1 "
+ " or(sum(t.normalConsumed+COALESCE(t.otConsumed, 0))/ COALESCE(p.totalManhour, 0)) >= :lowerLimit "
+ " and (sum(t.normalConsumed+COALESCE(t.otConsumed, 0))/ COALESCE(p.totalManhour, 0)) <= 1 "
+ " then'Potential Overconsumption' else'Within Budget' END as status "
+ " from "
+ " ( "
+ " SELECT t.*, (t.normalConsumed+COALESCE(t.otConsumed, 0)) * sal.hourlyRate as consumedBudget "
+ " FROM timesheet t "
+ " INNER JOIN salary_effective se ON se.staffId = t.staffId AND t.recordDate BETWEEN se.startDate AND se.endDate "
+ " LEFT JOIN salary sal on se.salaryId = sal.salaryPoint "
+ " ) t "
+ " left join project p on p.id = t.projectId "
+ " left join team tm on p.teamLead = tm.teamLead "
+ " left join customer c on c.id = p.customerId "
+ " left join subsidiary ss on p.customerSubsidiaryId = ss.id "
+ " WHERE p.deleted = false and p.status ='On-going' "
)
var statusFilter: String = ""
if (args != null) {


+ 0
- 1
src/main/java/com/ffii/tsms/modules/report/web/ReportController.kt Voir le fichier

@@ -172,7 +172,6 @@ class ReportController(
val args: MutableMap<String, Any> = mutableMapOf(
"status" to request.status,
"lowerLimit" to lowerLimit

)
if (request.teamId != null) {
args["teamId"] = request.teamId


Chargement…
Annuler
Enregistrer