<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.cf.imes.module.executor.dal.mysql.processStepItem.ProcessStepItemMapper">


    <select id="selectAreaByProcessStepId"
            resultType="com.cf.imes.module.executor.controller.admin.plan.bo.ProcessStepAreaIds">


        select distinct
            sum(op.area) as area,
            opsi.process_step_id as processStepId

        from order_process_step_item opsi
                 join order_body ob on opsi.body_id = ob.id and opsi.organ_id = ob.organ_id
                 join order_item oi on ob.id = oi.body_id and ob.organ_id = oi.organ_id
                 join order_plate op on oi.plate_id = op.id and oi.organ_id = op.organ_id

        where  opsi.organ_id = #{organId}
          and opsi.process_step_id in

        <foreach item="processStepId" collection="processStepId" open="(" separator="," close=")">
            #{processStepId}
        </foreach>

        group by opsi.process_step_id


    </select>


    <update id="updateStatus">


        update order_process_step_item
        SET status = TRUE

        WHERE process_step_id in

        <foreach item="processStepIds" collection="processStepIds" open="(" separator="," close=")">
            #{processStepIds}
        </foreach>


    </update>





</mapper>