<?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.jeeplus.test.wdt.disposeRubbish.mapper.DisposeRubbishMapper">
    <select id="getUserInfoByOffId" resultType="com.jeeplus.sys.service.dto.UserDTO">
        select su.id, su.name, su.mobile from sys_user su
        left join sys_office so on su.office_id = so.id
        left join sys_user_role sur on su.id = sur.user_id
        left join sys_role sr on sur.role_id = sr.id
        where su.office_id = #{officeId} and sr.name = '村负责人'
    </select>

    <select id="selectById" resultType="com.jeeplus.test.wdt.disposeRubbish.domain.DisposeRubbish">
        select
        a.id,
        a.create_by_id,
        a.create_time,
        a.update_by_id,
        a.update_time,
        a.del_flag,
        a.remarks,
        a.no,
        a.processing_unit,
        a.status,
        a.clear_user_id,
        a.dispose_type,
        a.rubbish_station,
        a.program_id,
        a.proc_ins_id,
        a.weight,
        a.transport_mileage,
        a.subsidy,
        a.year,
        a.number,
        so.name as processingUnitName,
        su.name as clearUserName,
        su.mobile as clearUserMobile
        from dispose_rubbish a
        left join sys_office so on a.processing_unit = so.id
        left join sys_user su on a.clear_user_id = su.id
        where a.id = #{id} and a.del_flag = 0
    </select>

    <select id="getByProcInsId" resultType="com.jeeplus.test.wdt.disposeRubbish.domain.DisposeRubbish">
        select
        a.id,
        a.create_by_id,
        a.create_time,
        a.update_by_id,
        a.update_time,
        a.del_flag,
        a.remarks,
        a.no,
        a.processing_unit,
        a.status,
        a.clear_user_id,
        a.dispose_type,
        a.rubbish_station,
        a.program_id,
        a.proc_ins_id,
        a.weight,
        a.transport_mileage,
        a.subsidy,
        a.year,
        a.number
        from dispose_rubbish a
        <where>
            a.proc_ins_id in
            <foreach collection="procInsIdList" item="procInsId" index="index" open="(" close=")" separator=",">
                #{procInsId}
            </foreach>
            and a.del_flag = 0
        </where>
    </select>
    <select id="getByAttachmentId" resultType="com.jeeplus.test.oss.domain.WorkAttachmentInfo">
        SELECT
            url,
            type,
            attachment_name as name,
            file_size as size
		FROM
			work_attachment
		WHERE
			del_flag = 0
			AND attachment_id = #{id}
    </select>
</mapper>
