zss
2024-07-24 d5fc264f0e99391677f6d008b9608da434b27c59
performance-server/src/main/resources/mapper/AuxiliaryOutputWorkingHoursMapper.xml
@@ -4,7 +4,9 @@
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.yuanchu.mom.pojo.AuxiliaryOutputWorkingHours">
        <id column="id" property="id"/>
        <result column="inspect_project" property="inspectProject"/>
        <result column="inspection_item" property="inspectionItem"/>
        <result column="inspection_item_subclass" property="inspectionItemSubclass"/>
        <result column="sample" property="sample"/>
        <result column="overtime_order_no" property="overtimeOrderNo"/>
        <result column="overtime_work_time" property="overtimeWorkTime"/>
        <result column="overtime_amount" property="overtimeAmount"/>
@@ -25,7 +27,8 @@
        select *
        from (
        select aowh.id,
        inspect_project,
        inspection_item,
        inspection_item_subclass,
        overtime_order_no,
        overtime_work_time,
        overtime_amount,
@@ -36,16 +39,17 @@
        date_time,
        week,
        week_day,
        name
        name,
        sample
        FROM auxiliary_output_working_hours aowh
        left join user on user.id=aowh.`check`
        WHERE `check` in(#{ids})
        <!--<if test="ids !=null and ids != ''">
            WHERE `check` in
        WHERE 1=1
        <if test="ids !=null and ids != ''">
            and `check` in
            <foreach collection="ids" index="index" open="(" separator="," close=")" item="val">
                #{val}
            </foreach>
        </if>-->
        </if>
        ) A
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
@@ -55,46 +59,72 @@
        select aowh.*,name
        FROM auxiliary_output_working_hours aowh
        left join user on user.id=aowh.`check`
        WHERE `check` in(#{ids})
        <!-- <if test="ids !=null and ids != ''">
             WHERE `check` in
             <foreach collection="ids" index="index" open="(" separator="," close=")" item="val">
                 #{val}
             </foreach>
         </if>-->
    </select>
    <select id="totalHours" resultType="java.util.Map">
        select A.name,
        A.month,
        A.manHours
        from(
        select user.name,
        date_time as month,
        sum(output_work_time) as manHours
        from auxiliary_output_working_hours aowh
        left join user on user.id=aowh.`check`
        left join department_lims dl on depart_lims_id=dl.id
        where date_time LIKE CONCAT('%', #{month}, '%')
        and `check` in (#{ids})
        <!--<if test="ids !=null and ids != ''">
            and `check` in (#ids)
            <foreach collection="ids" open="(" separator="," close=")" item="val">
                #{val}
            </foreach>
        </if>-->
        group by user.name,date_time
        order by user.name,date_time
        )A
    </select>
    <select id="selectListByIds" resultType="com.yuanchu.mom.pojo.AuxiliaryOutputWorkingHours">
        select * from auxiliary_output_working_hours
        where 1=1
        and `check` in(#{ids})
        <!--<if test="ids !=null and ids != ''">
        WHERE 1=1
        <if test="ids !=null and ids != ''">
            and `check` in
            <foreach collection="ids" index="index" open="(" separator="," close=")" item="val">
                #{val}
            </foreach>
        </if>-->
        </if>
    </select>
    <select id="totalHours" resultType="java.util.Map">
        select A.name,
        A.month,
        FORMAT(SUM(A.manHours), 4) manHours
        from(
        select user.name,
        date_time as month,
        order_no,
        sample,
        man_hour_group,
        case when #{type}='加班工时' then  case when overtime_work_time is null then 0 else overtime_work_time end
        else case when work_time is null then 0 else work_time end  end as manHours
        -- FORMAT(SUM(output_work_time), 4) as manHours
        from auxiliary_output_working_hours aowh
        left join user on user.id=aowh.`check`
        left join department_lims dl on depart_lims_id=dl.id
        where date_time LIKE CONCAT('%', #{month}, '%')
        <if test="ids !=null and ids != ''">
            and `check` in
            <foreach collection="ids" open="(" separator="," close=")" item="val">
                #{val}
            </foreach>
        </if>
        group by user.name,date_time,order_no,
        sample,
        man_hour_group
        order by user.name,date_time,order_no,
        sample,
        man_hour_group
        )A
        group by A.name,
        A.month
        order by A.name,
        A.month
    </select>
    <select id="selectListByIds" resultType="com.yuanchu.mom.pojo.AuxiliaryOutputWorkingHours">
        select * from auxiliary_output_working_hours
        where 1=1
        <if test="ids !=null and ids != ''">
            and `check` in
            <foreach collection="ids" index="index" open="(" separator="," close=")" item="val">
                #{val}
            </foreach>
        </if>
    </select>
    <select id="selectLists" resultMap="BaseResultMap">
        select * from(select * from auxiliary_output_working_hours
        WHERE 1=1
        <if test="ids !=null and ids != ''">
            and `check` in
            <foreach collection="ids" index="index" open="(" separator="," close=")" item="val">
                #{val}
            </foreach>
        </if>
        ) A
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
        </if>
    </select>
</mapper>