| | |
| | | SELECT glass_id, |
| | | order_number, |
| | | technology_number, |
| | | working_procedure |
| | | working_procedure, |
| | | type |
| | | FROM ( |
| | | SELECT glass_id, |
| | | order_number, |
| | | technology_number, |
| | | working_procedure, |
| | | type, |
| | | ROW_NUMBER() OVER ( |
| | | PARTITION BY glass_id |
| | | ORDER BY damage_time DESC |
| | |
| | | </if> |
| | | </where> |
| | | </select> |
| | | <select id="queryProgress" resultType="com.mes.damage.entity.vo.GlassDamageVO"> |
| | | SELECT |
| | | t.glass_id, |
| | | t.glass_type, |
| | | t.flow_card_id, |
| | | t.layer, |
| | | t1.damage_time, |
| | | t.width, |
| | | t.height, |
| | | t.thickness, |
| | | t.filmsid, |
| | | t2.process AS working_procedure, |
| | | t1.device_name, |
| | | ifnull(t1.type,0) as type, |
| | | ifnull(t1.status,0) as status, |
| | | t1.line, |
| | | t1.remark |
| | | FROM ( |
| | | SELECT '切割' AS process FROM DUAL |
| | | UNION ALL |
| | | SELECT '磨边' AS process FROM DUAL |
| | | UNION ALL |
| | | SELECT '钢化' AS process FROM DUAL |
| | | ) t2 |
| | | LEFT JOIN glass_info t ON |
| | | <!-- 抽离多字段IN条件:使用参数替换固定值 --> |
| | | (t.engineer_id, t.flow_card_id, t.layer, t.glass_type) IN |
| | | <foreach collection="conditionList" item="item" open="(" separator="," close=")"> |
| | | (#{item.engineerId},#{item.flowCardId}, #{item.layer}, #{item.glassType}) |
| | | </foreach> |
| | | <if test="workingProcedureList != null and workingProcedureList.size() > 0"> |
| | | AND t2.process IN |
| | | <foreach collection="workingProcedureList" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | <if test="glassId != null and glassId != ''"> |
| | | AND t.glass_id = #{glassId} |
| | | </if> |
| | | LEFT JOIN damage t1 ON t.glass_id = t1.glass_id AND t1.working_procedure = t2.process |
| | | where 1=1 |
| | | <!-- 抽离t1.type条件 --> |
| | | <if test="typeList != null and typeList.size() > 0"> |
| | | AND t1.type IN |
| | | <foreach collection="typeList" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | </select> |
| | | <select id="queryFlowCardIdProgress" resultType="com.mes.damage.entity.vo.FlowCardDamageVO"> |
| | | WITH glass_info_result AS ( |
| | | SELECT |
| | | engineer_id, |
| | | flow_card_id, |
| | | layer, |
| | | glass_type, |
| | | thickness, |
| | | filmsid, |
| | | width, |
| | | height, |
| | | count(*) AS total_quantity |
| | | FROM |
| | | glass_info |
| | | WHERE |
| | | 1=1 |
| | | <if test="flowCardId != null and flowCardId != ''"> |
| | | AND flow_card_id = #{flowCardId} |
| | | </if> |
| | | <if test="engineerId != null and engineerId != ''"> |
| | | AND engineer_id = #{engineerId} |
| | | </if> |
| | | <if test="glassId != null and glassId != ''"> |
| | | and (flow_card_id, layer, glass_type) IN (select flow_card_id, layer, glass_type from glass_info where |
| | | glass_id=#{glassId} ) |
| | | </if> |
| | | GROUP BY |
| | | engineer_id, |
| | | flow_card_id, |
| | | layer, |
| | | glass_type, |
| | | thickness, |
| | | filmsid, |
| | | width, |
| | | height |
| | | ), |
| | | damage_result AS ( |
| | | SELECT |
| | | engineer_id, |
| | | process_id, |
| | | technology_number, |
| | | order_number, |
| | | working_procedure, |
| | | type, |
| | | count(*) AS report_quantity |
| | | FROM |
| | | damage |
| | | WHERE |
| | | 1=1 |
| | | <if test="flowCardId != null and flowCardId != ''"> |
| | | AND process_id = #{flowCardId} |
| | | </if> |
| | | <if test="engineerId != null and engineerId != ''"> |
| | | AND engineer_id = #{engineerId} |
| | | </if> |
| | | <if test="glassId != null and glassId != ''"> |
| | | AND (process_id, technology_number, order_number) IN (select flow_card_id, layer, glass_type from glass_info |
| | | where glass_id=#{glassId} ) |
| | | </if> |
| | | GROUP BY |
| | | engineer_id, |
| | | process_id, |
| | | technology_number, |
| | | order_number, |
| | | working_procedure, |
| | | type |
| | | ), |
| | | final_result AS ( |
| | | SELECT |
| | | t.*, |
| | | sum( CASE WHEN t1.working_procedure = "切割" AND t1.type = 1 THEN report_quantity ELSE 0 END ) - |
| | | sum( CASE WHEN (t1.working_procedure = "磨边" or t1.working_procedure="钢化" or t1.working_procedure="中空") AND |
| | | t1.type = 8 THEN report_quantity ELSE 0 END ) AS cutting, |
| | | sum( CASE WHEN t1.working_procedure = "磨边" AND t1.type = 1 THEN report_quantity ELSE 0 END ) - |
| | | sum( CASE WHEN (t1.working_procedure="钢化" or t1.working_procedure="中空") AND t1.type = 8 THEN report_quantity |
| | | ELSE 0 END ) AS edging, |
| | | sum( CASE WHEN t1.working_procedure = "钢化" AND t1.type = 1 THEN report_quantity ELSE 0 END ) - |
| | | sum( CASE WHEN (t1.working_procedure="中空") AND t1.type = 8 THEN report_quantity ELSE 0 END ) AS temping |
| | | FROM |
| | | glass_info_result t |
| | | LEFT JOIN damage_result t1 ON t.engineer_id = t1.engineer_id |
| | | AND t.flow_card_id = t1.process_id |
| | | AND t.layer = t1.technology_number |
| | | AND t.glass_type = t1.order_number |
| | | GROUP BY |
| | | t.engineer_id, |
| | | t.flow_card_id, |
| | | t.layer, |
| | | t.glass_type, |
| | | t.thickness, |
| | | t.filmsid, |
| | | t.width, |
| | | t.height, |
| | | t.total_quantity |
| | | order by |
| | | t.engineer_id, |
| | | t.flow_card_id, |
| | | t.glass_type, |
| | | t.layer |
| | | ) |
| | | select * from final_result; |
| | | </select> |
| | | </mapper> |