<?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.materialManagement.wareHouse.mapper.WareHouseBasicMapper">
    <select id="findList" resultType="com.jeeplus.test.materialManagement.wareHouse.service.dto.WareHouseDto">
		SELECT
			a.id,
			a.create_by,
			a.create_date,
			a.ware_house_number,
			a.ware_house_name,
			a.ware_house_date,
			a.handled_by,
			a.handled_by_office,
			so.name as handledByOfficeName,
			sy.name as handleByName,
			a.proc_ins_id,
			a.process_definition_id,
			ifnull(a.status,'0') as status
		FROM
			material_management_warehouse_basics a
			left join sys_office so on a.handled_by_office = so.id
			left join sys_user sy on sy.id = a.handled_by
			${ew.customSqlSegment}
		ORDER BY a.update_date DESC
    </select>
	<select id="getUserNameByUserId" resultType="java.lang.String">
		select name from sys_user where id = #{id}
	</select>
    <select id="summaryList"
            resultType="com.jeeplus.test.materialManagement.wareHouse.service.dto.WareHouseDto">
		SELECT
			a.id,
			a.create_by,
			a.create_date,
			c.ware_house_number,
			a.ware_house_type,
			a.trade_name,
			a.trade_number,
			b.company,
			c.ware_house_date,
			so.name as wareHouseManOfficeName,
			sy.name as wareHouseManName,
			d.name as wareHouseTypeName
		FROM
			material_management_warehouse_summary a
			left join material_management_warehouse_detailed b on a.detailed_id = b.id and b.del_flag = 0
			left join sys_user sy on sy.id = b.ware_house_man
			left join sys_office so on sy.office_id = so.id
			left join material_management_warehouse_basics c on b.basic_id = c.id and c.del_flag = 0
			left join cw_reimbursement_type_info d on a.ware_house_type = d.id
			${ew.customSqlSegment}
		ORDER BY a.update_date DESC
	</select>
    <select id="findRequestId" resultType="java.lang.String">
		select id from material_management_pruchase_request_basics where purchase_no = #{purchaseNo} and del_flag = 0
	</select>
</mapper>
