<?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.unis.crk.basic.mapper.BasicStorehouseMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.unis.crk.basic.entity.BasicStorehouse">
        <id column="storehouse_id" property="storehouseId"/>
        <result column="uuid" property="uuid"/>
        <result column="depot_id" property="depotId"/>
        <result column="depot_name" property="depotName"/>
        <result column="org_id" property="orgId"/>
        <result column="org_name" property="orgName"/>
        <result column="storehouse_code" property="storehouseCode"/>
        <result column="storehouse_name" property="storehouseName"/>
        <result column="storehouse_type" property="storehouseType"/>
        <result column="storehouse_type_mx" property="storehouseTypeMx"/>
        <result column="architecture_type" property="architectureType"/>
        <result column="store_img" property="storeImg"/>
        <result column="ground" property="ground"/>
        <result column="wall" property="wall"/>
        <result column="roof" property="roof"/>
        <result column="house" property="house"/>
        <result column="design_capacity" property="designCapacity"/>
        <result column="keeping_way" property="keepingWay"/>
        <result column="grain_heigth" property="grainHeigth"/>
        <result column="store_outside_length" property="storeOutsideLength"/>
        <result column="store_outside_width" property="storeOutsideWidth"/>
        <result column="store_outside_heigth" property="storeOutsideHeigth"/>
        <result column="store_outside_top_heigth" property="storeOutsideTopHeigth"/>
        <result column="outside_silo_diameter" property="outsideSiloDiameter"/>
        <result column="outer_wall_area" property="outerWallArea"/>
        <result column="deduct_volume" property="deductVolume"/>
        <result column="length" property="length"/>
        <result column="width" property="width"/>
        <result column="heigth" property="heigth"/>
        <result column="grain_line_heigth" property="grainLineHeigth"/>
        <result column="silo_diameter" property="siloDiameter"/>
        <result column="bin_volume" property="binVolume"/>
        <result column="grain_pile_volume" property="grainPileVolume"/>
        <result column="house_door_num" property="houseDoorNum"/>
        <result column="house_doot_position" property="houseDootPosition"/>
        <result column="house_door_width" property="houseDoorWidth"/>
        <result column="house_door_heigth" property="houseDoorHeigth"/>
        <result column="draftType" property="draftType"/>
        <result column="heatInsulationStep_roof" property="heatinsulationstepRoof"/>
        <result column="heatInsulationStep_window" property="heatinsulationstepWindow"/>
        <result column="grbwcs" property="grbwcs"/>
        <result column="nfszcc" property="nfszcc"/>
        <result column="ywfsfqfczz" property="ywfsfqfczz"/>
        <result column="ywfhfbfdss" property="ywfhfbfdss"/>
        <result column="ywlqjcss" property="ywlqjcss"/>
        <result column="ywjxtfss" property="ywjxtfss"/>
        <result column="nfhlxzsc" property="nfhlxzsc"/>
        <result column="nffddyqtcl" property="nffddyqtcl"/>
        <result column="nfcwcc" property="nfcwcc"/>
        <result column="actual_capacity" property="actualCapacity"/>
        <result column="completion_date" property="completionDate"/>
        <result column="useDate" property="useDate"/>
        <result column="storehouse_state" property="storehouseState"/>
        <result column="store_way" property="storeWay"/>
        <result column="currentType" property="currentType"/>
        <result column="dutyStoreman" property="dutyStoreman"/>
        <result column="remark" property="remark"/>
        <result column="createName" property="createName"/>
        <result column="createDate" property="createDate"/>
        <result column="updateName" property="updateName"/>
        <result column="updateDate" property="updateDate"/>
        <result column="working_status" property="workingStatus"/>
        <result column="del_flag" property="delFlag"/>
        <result column="library_type" property="libraryType"/>
        <result column="updatetime" property="updatetime"/>
        <result column="datatype" property="datatype"/>
       <!-- <result column="hwbm" property="hwbm"/>-->
        <result column="cclx" property="cclx"/>
        <result column="fssssfwh" property="fssssfwh"/>
        <result column="tankType" property="tankType"/>
        <result column="ywjrzz" property="ywjrzz"/>
        <result column="diameter" property="diameter"/>
        <result column="height" property="height"/>
        <result column="verificationMethod" property="verificationMethod"/>
        <result column="weldingMethod" property="weldingMethod"/>
        <result column="tankStatus" property="tankStatus"/>
        <result column="bottomArea" property="bottomArea"/>
        <result column="designedStorageHeight" property="designedStorageHeight"/>
        <result column="outOilHeight" property="outOilHeight"/>
        <result column="type" property="type"/>

    </resultMap>

    <select id="getStorehouseList" resultType="java.util.Map">
  SELECT * FROM ( SELECT
	'0' AS "isOil",
	storehouse_name AS "storehouse_name",
	storehouse_code AS "storehouse_code",
	cast(storehouse_id as char) AS "storehouse_id"
FROM
	basic_storehouse
WHERE
	org_id = #{unitId}
AND library_type != '1'
AND del_flag != '0'and  del_flag != 2
UNION ALL
	SELECT
		'1' AS "isOil",
		storageTank_name AS "storehouse_name",
		storageTank_code AS "storehouse_code",
		cast(id as char)  AS "storehouse_id"
	FROM
		basic_tank
	WHERE
		org_id = #{unitId}
	AND del_flag != 2 ) x  ORDER BY isOil,storehouse_code
    </select>

    <select id="getStorehouseListByCclx" resultType="java.util.Map">
        SELECT * FROM ( SELECT
            '0' AS "isOil",
            storehouse_name AS "storehouse_name",
            storehouse_code AS "storehouse_code",
            cast(storehouse_id as char) AS "storehouse_id"
        FROM
            basic_storehouse
        WHERE
            org_id = #{unitId}
        AND library_type != '1'
        AND del_flag != '0'and  del_flag != 2
        UNION ALL
            SELECT
                '1' AS "isOil",
                storageTank_name AS "storehouse_name",
                storageTank_code AS "storehouse_code",
                cast(id as char)  AS "storehouse_id"
            FROM
                basic_tank
            WHERE
                org_id = #{unitId}
            AND del_flag != 2 ) x  ORDER BY isOil,storehouse_code
    </select>
    <select id="selectMyMapsPage" resultType="java.util.Map">
        SELECT
        a.storehouse_id,
        a.uuid,
        a.depot_id,
        a.depot_name,
        a.org_id,
        a.org_name,
        a.storehouse_code,
        a.storehouse_name,
        a.storehouse_type,
        a.storehouse_type_mx,
        a.architecture_type,
        a.store_img,
        a.ground,
        a.wall,
        a.roof,
        a.house,
        a.design_capacity,
        a.keeping_way,
        a.grain_heigth,
        a.store_outside_length,
        a.store_outside_width,
        a.store_outside_heigth,
        a.store_outside_top_heigth,
        a.outside_silo_diameter,
        a.outer_wall_area,
        a.deduct_volume,
        a.length,
        a.width,
        a.heigth,
        a.grain_line_heigth,
        a.silo_diameter,
        a.bin_volume,
        a.grain_pile_volume,
        a.house_door_num,
        a.house_doot_position,
        a.house_door_width,
        a.house_door_heigth,
        a.draftType,
        a.heatInsulationStep_roof,
        a.heatInsulationStep_window,
        a.grbwcs,
        a.nfszcc,
        a.ywfsfqfczz,
        a.ywfhfbfdss,
        a.ywlqjcss,
        a.ywjxtfss,
        a.nfhlxzsc,
        a.nffddyqtcl,
        a.nfcwcc,
        a.actual_capacity,
        a.completion_date,
        a.useDate,
        a.storehouse_state,
        a.store_way,
        a.currentType,
        a.dutyStoreman,
        a.remark,
        a.createName,
        a.createDate,
        a.updateName,
        a.updateDate,
        a.working_status,
        a.del_flag,
        a.library_type,
        a.updatetime,
        a.datatype,
      /*  a.hwbm,
        a.actualCapacity,*/
        b.enumName as "storehouse_type_name",
        c.enumName as "storehouse_state_name"
        FROM basic_storehouse a LEFT JOIN basic_enum b on a.storehouse_type=b.enumId
        LEFT JOIN basic_enum c on a.storehouse_state = c.enumId
        <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
            where ${ew.sqlSegment}
        </if>
    </select>
</mapper>
