MyBatis文件:AssetMapper.xml
<?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.topnpl.web.asset.mapper.AssetMapper">
<!-- 资产地图各种统计 -->
<select id="getMapCharts" resultType="java.util.HashMap" statementType="CALLABLE" >
{call MAP_CHARTS(
#{type, jdbcType=INTEGER, mode=IN},
#{locationId, jdbcType=INTEGER, mode=IN}
)}
</select>
</mapper>
存储过程:
CREATE DEFINER=`root`@`%` PROCEDURE `MAP_CHARTS`(IN `type` INT ( 1 ), IN `locationId` INT ( 15 ))
BEGIN
# 当前区名,当前区所在的市名
IF type = 1 or type =0 THEN
SELECT
location_name AS countryName,
parent_id AS parentId,
(SELECT location_name FROM topnpl_location WHERE id = parentId) AS cityName
FROM
topnpl_location
WHERE
isdel = 0
AND id = locationId;
END IF;
# 当前区市场均价
IF type = 2 or type = 0 THEN
SELECT
market_price marketAvg
FROM
topnpl_market_avg_price
WHERE
year_and_month = DATE_FORMAT(CURDATE(), '%Y-%m')
AND location_id = locationId;
END IF;
END