<?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.pubmodules.purchase.mapper.MaterialDetailedMapper">
    <select id="getByBasicId" resultType="com.jeeplus.pubmodules.purchase.domain.MaterialDetailed">
        select a.*,su.name as purchaserAgent,su.id as purchaserAgentId,
        so.name as procurementOffice,d.id as procurementTypeId, d.name as procurementType
        from material_management_pruchase_request_detailed a
        left join sys_user su on a.purchaser_agent = su.id
        left join sys_office so on su.office_id = so.id
        left join material_management_type d on a.procurement_type = d.id
        where a.basic_id = #{basicId} and a.del_flag = '0'
    </select>
    <select id="getByAttachmentId" resultType="com.jeeplus.pubmodules.oss.service.dto.WorkAttachmentDto">
        SELECT
			id,
			url,
			attachment_name AS `name`,
			create_by_id AS `by`,
			create_time
		FROM
			work_attachment
		WHERE
			del_flag = 0
			AND attachment_id = #{id}
    </select>
    <select id="getIdByBasicId" resultType="java.lang.String">
        select a.id from material_management_pruchase_request_detailed a where a.basic_id = #{id} and a.del_flag = 0
    </select>

    <select id="getByTypeId" resultType="com.jeeplus.pubmodules.purchase.domain.MaterialDetailed">
        SELECT
            id,
            trade_name
        FROM
            material_management_warehouse_detailed
        WHERE
            del_flag = '0'
            AND ware_house_type = #{typeId}
        GROUP BY
            trade_name
        ORDER BY
            create_time DESC
    </select>
</mapper>
