select a.project_no,
1 as glass_type,
a.width,
a.height,
REGEXP_REPLACE(b.glass_thickness, '\\D', '') as glass_thickness,
a.heat_layout_sort,
0 as state
from optimize_detail a
left join optimize_project b on a.project_no = b.project_no
where a.project_no = #{projectNo}
select p.project_no,
p.project_name,
p.glass_thickness,
p.glass_type,
p.glass_total,
p.glass_total_area
from pp.optimize_project p
where p.state = 100
and p.project_no not in (select es.project_no
from north_glass_mes.engineer_scheduling es
where es.project_no is not null)
order by p.id
select es.project_no,
es.project_name,
es.type,
p.glass_thickness,
p.glass_type,
p.glass_total,
p.glass_total_area,
IFNULL(e.state,0) as state
from north_glass_mes.engineer_scheduling es
left join pp.optimize_project p on es.project_no=p.project_no
left join north_glass_mes.engineering e on es.project_no=e.engineer_id
where es.state = 100
and es.type = #{type}
order by case when IFNULL(e.state, 0) = 1 then 0 else 1 end, es.id
DELETE
FROM north_glass_mes.engineer_scheduling
WHERE type = #{type}
DELETE
FROM north_glass_mes.engineer_scheduling
WHERE project_no = #{engineerId}
and type in (
#{item}
)
INSERT INTO north_glass_mes.engineer_scheduling (
project_no,
project_name,
state,
type
) VALUES
(
#{item.projectNo},
#{item.projectName},
#{item.state},
#{item.type}
)
SELECT
a.engineer_id,
a.flow_card_id,
a.layer,
a.glass_type,
a.thickness,
a.filmsid,
a.width,
a.height,
COUNT(a.glass_id) as glassIdCount,
SUM(CASE WHEN d.working_procedure = '切割' AND d.type = 1 THEN 1 ELSE 0 END) as cuttingCount,
SUM(CASE WHEN d.working_procedure = '磨边' AND d.type = 1 THEN 1 ELSE 0 END) as edgingCount,
SUM(CASE WHEN d.working_procedure = '钢化' AND d.type = 1 THEN 1 ELSE 0 END) as temperingCount,
SUM(CASE WHEN d.working_procedure = '中空' AND d.type = 1 THEN 1 ELSE 0 END) as insulatingCount
FROM
north_glass_mes.glass_info a
LEFT JOIN
north_glass_mes.damage d
ON a.glass_id = d.glass_id
AND a.engineer_id = d.engineer_id
WHERE
a.engineer_id = #{engineerId}
GROUP BY
a.engineer_id,
a.flow_card_id,
a.layer,
a.glass_type,
a.thickness,
a.filmsid,
a.width,
a.height