Mybatis封装多个ResultMap

<?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.wlyd.wmscloud.persistence.mapper.platform.StatisticalChartsMapper">
    
    <resultMap id="UnProcesssTaskResultMap"    type="com.wlyd.wmscloud.persistence.beans.platform.UnProcessTask">
        <result column="intoPlanItemSum" property="intoPlanItemSum"    jdbcType="INTEGER" />
        <result column="intoPlanItemSum" property="intoPlanItemSum"    jdbcType="INTEGER" />
        <result column="intoPlanItemSum" property="intoPlanItemSum"    jdbcType="INTEGER" />
    </resultMap>
    
    <resultMap id="ItemsOfTodayResultMap"    type="com.wlyd.wmscloud.persistence.beans.platform.ItemsOfToday">
        <result column="intoItemSum" property="intoItemSum"    jdbcType="INTEGER" />
        <result column="outItemSum" property="outItemSum"    jdbcType="INTEGER" />
    </resultMap>
    
    <resultMap id="WarehouseSituationResultMap"    type="com.wlyd.wmscloud.persistence.beans.platform.WarehouseSituation">
        <result column="warehouseSum" property="warehouseSum"    jdbcType="INTEGER" />
        <result column="locationSum" property="locationSum"    jdbcType="INTEGER" />
        <result column="usingLocationNum" property="usingLocationNum"    jdbcType="INTEGER" />
        <result column="freeLocationNum" property="freeLocationNum"    jdbcType="INTEGER" />
    </resultMap>
    
    <resultMap id="WarehouseLocationUsingResultMap"    type="com.wlyd.wmscloud.persistence.beans.platform.WarehouseLocationUsing">
        <result column="warehouseName" property="warehouseName"    jdbcType="VARCHAR" />
        <result column="locationSum" property="locationSum"    jdbcType="INTEGER" />
        <result column="usingLocationNum" property="usingLocationNum"    jdbcType="INTEGER" />
    </resultMap>

    <select id="countUnPorcessTasks" resultMap="UnProcesssTaskResultMap">
       SELECT (SELECT count(WMIO_CODE) FROM wm_into_order_${esCorCode}  WHERE WMIO_STATE=0) intoPlanItemSum ,
              (SELECT count(WMIO_CODE) FROM wm_into_order_${esCorCode}  WHERE WMIO_STATE=2) receiveItemSum,
              (SELECT count(WMOO_CODE) FROM wm_out_order_${esCorCode}  WHERE WMOO_STATUS not in (6,7)) outConfirmSum
    </select>
    
    <select id="countItemsOfToday" resultMap="ItemsOfTodayResultMap">
       SELECT (SELECT SUM(WMST_NOW_NUMBER) FROM wm_stock_${esCorCode}  WHERE WMST_RECEIVE_DATE > #{today,jdbcType=TIMESTAMP} ) intoItemSum,
              (SELECT SUM(WMOO_OUT_NUMBER) FROM wm_out_order_${esCorCode}  WHERE WMOO_STATUS=6)  outItemSum
    </select>
    
    <select id="countWarehouseSituation" resultMap="WarehouseSituationResultMap">
    SELECT (SELECT COUNT(CDWA_CODE) FROM cd_warehouse_${esCorCode} ) warehouseSum,
            (SELECT COUNT(CDLC_LOCATION_CODE) FROM cd_wh_location_${esCorCode} ) locationSum,
            (SELECT COUNT(WMST_WH_LOC_ID) usingLocationNum  FROM ( SELECT DISTINCT (WMST_WH_LOC_ID) from wm_stock_${esCorCode} ) DISTINCT_FIELD ) usingLocationNum,
            (SELECT locationSum-usingLocationNum) freeLocationNum;
    </select>
    
    <select id="countWarehouseLocationUsing" resultMap="WarehouseLocationUsingResultMap">
    SELECT  CDWH.CDWA_NAME warehouseName,COUNT(CDCL.CDLC_LOCATION_CODE) locationSum,IFNULL(WMST.WMST_COUNT,0) usingLocationNum FROM cd_warehouse_${esCorCode} CDWH
           LEFT JOIN cd_wh_location_${esCorCode} CDCL  ON  CDCL.CDLC_WAREHOUSE_ID=CDWH.CDWA_ID 
           LEFT JOIN ( SELECT SSD2.WMST_WR_ID,COUNT(SSD2.WMST_WH_LOC_ID) WMST_COUNT FROM (SELECT  DISTINCT SSD.WMST_WH_LOC_ID,SSD.WMST_WR_ID  FROM wm_stock_${esCorCode} SSD ) SSD2 GROUP BY SSD2.WMST_WR_ID ) WMST ON  WMST.WMST_WR_ID=CDWH.CDWA_ID 
           GROUP BY CDWH.CDWA_NAME
    </select>
    <select id="callProcedureToAddItemTransfer" statementType="CALLABLE"    resultType="String">
        { call P_ITEM_TRANSFER()}
    </select>
</mapper>

package com.wlyd.wmscloud.persistence.mapper.platform;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.wlyd.wmscloud.persistence.beans.platform.ItemsOfToday;
import com.wlyd.wmscloud.persistence.beans.platform.UnProcessTask;
import com.wlyd.wmscloud.persistence.beans.platform.WarehouseLocationUsing;
import com.wlyd.wmscloud.persistence.beans.platform.WarehouseSituation;

public interface StatisticalChartsMapper {
    
    UnProcessTask countUnPorcessTasks(@Param("esCorCode") String esCorCode);
    
    ItemsOfToday countItemsOfToday(@Param("esCorCode") String esCorCode,@Param("today") String today );
    
    WarehouseSituation countWarehouseSituation(@Param("esCorCode")String esCorCode);
    
    List<WarehouseLocationUsing> countWarehouseLocationUsing(@Param("esCorCode")String esCorCode);
    
    String callProcedureToAddItemTransfer();
}


你可能感兴趣的:(mybatis,resultMap)