|
|
|
@@ -36,9 +36,17 @@ interface ProductionScheduleRepository : AbstractRepository<ProductionSchedule, |
|
|
|
ps.totalFGType, |
|
|
|
ps.`type` |
|
|
|
from production_schedule ps |
|
|
|
), |
|
|
|
ranked_prod as ( |
|
|
|
select |
|
|
|
*, |
|
|
|
row_number() over (partition by date(schedulePeriod) and date(schedulePeriodTo) order by scheduleAt desc) as rn |
|
|
|
from prod |
|
|
|
where deleted = false |
|
|
|
) |
|
|
|
select * from prod |
|
|
|
select * from ranked_prod |
|
|
|
where deleted = false |
|
|
|
and rn = 1 |
|
|
|
and (:scheduleAt = '' or datediff(scheduleAt, coalesce(:scheduleAt, scheduleAt)) = 0) |
|
|
|
and (:schedulePeriod = '' or datediff(schedulePeriod, coalesce(:schedulePeriod, schedulePeriod)) = 0) |
|
|
|
and (:schedulePeriodTo = '' or datediff(schedulePeriodTo, coalesce(:schedulePeriodTo, schedulePeriodTo)) = 0) |
|
|
|
@@ -59,9 +67,17 @@ interface ProductionScheduleRepository : AbstractRepository<ProductionSchedule, |
|
|
|
ps.totalFGType, |
|
|
|
ps.`type` |
|
|
|
from production_schedule ps |
|
|
|
), |
|
|
|
ranked_prod as ( |
|
|
|
select |
|
|
|
*, |
|
|
|
row_number() over (partition by date(schedulePeriod) and date(schedulePeriodTo) order by scheduleAt desc) as rn |
|
|
|
from prod |
|
|
|
where deleted = false |
|
|
|
) |
|
|
|
select count(*) from prod |
|
|
|
select count(*) from ranked_prod |
|
|
|
where deleted = false |
|
|
|
and rn = 1 |
|
|
|
and (:scheduleAt = '' or datediff(scheduleAt, coalesce(:scheduleAt, scheduleAt)) = 0) |
|
|
|
and (:schedulePeriod = '' or datediff(schedulePeriod, coalesce(:schedulePeriod, schedulePeriod)) = 0) |
|
|
|
and (:schedulePeriodTo = '' or datediff(schedulePeriodTo, coalesce(:schedulePeriodTo, schedulePeriodTo)) = 0) |
|
|
|
@@ -84,16 +100,21 @@ interface ProductionScheduleRepository : AbstractRepository<ProductionSchedule, |
|
|
|
nativeQuery = true, |
|
|
|
value = |
|
|
|
""" |
|
|
|
select |
|
|
|
ps.id, |
|
|
|
ps.deleted, |
|
|
|
ps.scheduleAt, |
|
|
|
ps.produceAt, |
|
|
|
ps.totalEstProdCount, |
|
|
|
ps.totalFGType, |
|
|
|
ps.`type` |
|
|
|
from production_schedule ps |
|
|
|
where deleted = false |
|
|
|
select * |
|
|
|
from ( |
|
|
|
select |
|
|
|
ps.id, |
|
|
|
ps.deleted, |
|
|
|
ps.scheduleAt, |
|
|
|
ps.produceAt, |
|
|
|
ps.totalEstProdCount, |
|
|
|
ps.totalFGType, |
|
|
|
ps.`type`, |
|
|
|
row_number() over (partition by date(ps.produceAt) order by ps.scheduleAt desc) as rn |
|
|
|
from production_schedule ps |
|
|
|
where deleted = false |
|
|
|
) ranked_prod |
|
|
|
where rn = 1 |
|
|
|
and produceAt is not null |
|
|
|
and scheduleAt in (select max(ps2.scheduleAt) from production_schedule ps2 group by ps2.produceAt) |
|
|
|
-- and (:scheduleAt = '' or datediff(scheduleAt, coalesce(:scheduleAt, scheduleAt)) = 0) |
|
|
|
@@ -215,7 +236,7 @@ interface ProductionScheduleRepository : AbstractRepository<ProductionSchedule, |
|
|
|
where psl.deleted is false and pe.prodTimeInMinute is not null and pm.bomMaterials is not null |
|
|
|
and ps.id = :id |
|
|
|
group by psl.id, jo.id, pp.proportion, pm.bomOutputQty, uc.udfudesc |
|
|
|
) prod group by prod.id limit 1 |
|
|
|
) prod group by prod.id limit 1; |
|
|
|
""" |
|
|
|
) |
|
|
|
fun findDetailedProdScheduleWithLine(id: Long): DetailedProdScheduleWithLineWithJsonString? |